In Firefox, you need to enclose the filename in double quotes to get the name you want, or if you have a space, you will lose the part behind the space.
And IE will turn the space to _, so also need to Httputility.urlpathencode method to deal with the next name.
If Firefox also uses Httputility.urlpathencode to process names, spaces will be replaced with "%20".
1HttpContext.Current.Response.Buffer =true;2 HttpContext.Current.Response.ClearContent ();3 HttpContext.Current.Response.ClearHeaders ();4HttpContext.Current.Response.ContentType ="application/pdf";5 stringDoc1 = System.IO.Path.GetFileNameWithoutExtension (doc) +"_"+ intnewid.tostring () +". pdf";6 7 if(HttpContext.Current.Request.Browser.Browser! ="IE")8HttpContext.Current.Response.AddHeader ("content-disposition","attachment;filename=\ ""+doc1+"\"");9 ElseTenHttpContext.Current.Response.AddHeader ("content-disposition","attachment;filename="+Httputility.urlpathencode (Doc1)); One byte[] buffer=System.IO.File.ReadAllBytes (DOC); AHttpContext.Current.Response.AddHeader ("Content-length", buffer. Length.tostring ()); -HttpContext.Current.Response.BinaryWrite (buffer);
Content-disposition attachment filename has different results in Firefox and IE