OK. I'm sure it does download XML files with the .xml extension, but I'm wondering what is missing in the code here to cause the .xml extenstion to be missing from the downloaded file.
Note: This works in IE 6+ (didn't try WebKit based browsers or Opera)
private void GenerateXmlAttachment(string xmlInStringFormat, string fileName)
{
// Where fileName = "someFile.xml"
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.Charset = string.Empty;
response.ContentEncoding = Encoding.Default;
response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
response.AddHeader("Content-Length", xmlInStringFormat.Length.ToString());
response.ContentType = "text/xml";
response.Write(xmlInStringFormat);
response.Flush();
response.End();
}
Ideas anyone?