I have a custom handler that implements IHttpHandler. Custom handler allows us to create a dynamic URL-address to download files people.
The code is as follows:
public void ProcessRequest(HttpContext context) { context.Response.AddHeader("Content-Disposition", "attachment;filename=" + attachment.FileName); context.Response.AddHeader("Content-Length", attachment.Fileblob.Length.ToString()); context.Response.ContentType = GetMimeType(attachment.FileName); context.Response.OutputStream.Write(attachment.Fileblob, 0, attachment.Fileblob.Length); }
The problem with investing. File name. If the file has a space,
filename - 1.bmp
Then, in the Internet explorer it works fine, but in firefox the file download dialog box truncates it so
file name
No extension or anything else. I also tried this,
attachment.FileName.Replace (","% 20 ")
Which works in IE again, but in firefox this causes the file name to be set to this download dialog,
filename% 20-% 201.bmp
I also tried it,
HttpUtility.UrlEncode (attachment.FileName)
In both Firefox and the IE, which leads to it,
filename + - + 1.bmp
Any ideas?
source share