I have a resource handler which is Response.WriteFile (filename) based on the parameter passed through the request. I handle mimetype correctly, but the problem is in some browsers, the file name appears as Res.ashx (handler name) instead of MyPdf.pdf (the file I output). Can someone tell me how to change the file name when sending it back to the server? Here is my code:
string application = context.Request.QueryString["a"];
string resource = context.Request.QueryString["r"];
string[] extensionArray = resource.Split(".".ToCharArray());
if (extensionArray.Length > 0)
context.Response.ContentType = MimeHandler.GetContentType(
extensionArray[extensionArray.Length - 1].ToLower());
application = (string.IsNullOrEmpty(application)) ?
"../App_Data/" : application.Replace("..", "");
resource = (string.IsNullOrEmpty(resource)) ?
"" : resource.Replace("..", "");
string url = "./App_Data/" + application + "/" + resource;
context.Response.WriteFile(url);
source
share