2010-05-27 73 views
1

错误是类似的东西: alt text http://i020.radikal.ru/1005/76/e94bd2f2c61f.jpg无法发送从Web应用程序文件在Internet Explorer

无法从192.168.0.172

加载Items.aspx

和文本是无法打开此网站。它找不到。请稍后尝试

代码:

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(); 

麻烦与此文件只适用于Internet Explorer(适用于歌剧/火狐...)

而且所以它适用于HTML,没有

HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; 

这个字符串

如何在IE上避免这个错误?

回答

1

尝试这样的:

HttpContext.Current.Response.Clear(); 
HttpContext.Current.Response.ClearHeaders(); 
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.AddHeader("Content-Type", "application/ms-excel"); 
HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", outputFileName)); 
HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble()); 
... 
table.RenderControl(htw);  
HttpContext.Current.Response.Write(sw.ToString()); 
HttpContext.Current.Response.Flush(); 
HttpContext.Current.Response.End(); 
+0

的麻烦是在SSL),但也帮助> _ <谢谢 – Cynede 2010-05-27 11:01:28

相关问题