Can't sent xml file from Web Application on Internet Explorer
- by nCdy
Error is something like that :
Can't load Items.aspx from 192.168.0.172
And a text is Can't open this web-site. It can't be found. Try later
code :
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Charset = System.Text.Encoding.Unicode.EncodingName;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode;
HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AddHeader(
"content-disposition", string.Format(
"attachment; filename={0}",fileName));
....
table.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
Trouble with this file is only for Internet Explorer (works on opera / firefox ... )
And so it works for HTML with no
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
this string