2010-05-27 62 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

相關問題