2010-05-27 1 views
1

erreur est quelque chose comme ça: alt text http://i020.radikal.ru/1005/76/e94bd2f2c61f.jpgImpossible d'envoyer le fichier à partir de l'application Web sur Internet Explorer

Impossible de charger Items.aspx de 192.168.0.172

Et un texte ne peut pas ouvrir ce site Internet. Il ne peut pas être trouvé. Essayez plus tard

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

Problème avec ce fichier est uniquement pour Internet Explorer (fonctionne sur l'opéra/FireFox ...)

Et donc cela fonctionne pour HTML sans

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

cette chaîne

Comment éviter cette erreur sur IE?

Répondre

1

Essayez comme ceci:

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

la peine était sur SSL) mais aussi aidé> _ Cynede

Questions connexes