I am trying to download a file from a fileserver that has contains an equal sign but it is being stripped out. I have the following method in my controller (see code below).
Note that in the highlighted line of code surrounding the filename with double-quotes works fine for other special characters ($, #, @, &, etc) but equal signs are stripped out.
Is there something special I have to do, some way to escape the equal sign to make sure the downloaded file name retains the equal sign?
Thanks,
Brad
---------------------------------------------
protected FileStreamResult StreamFileToHttpResponse(Stream stream, string fileName, bool streamRawFile = false)
{
FileStreamResult nullResponse = null;
if (stream != null && !string.IsNullOrEmpty(fileName))
{
//Identify MimeType and Return to Browser as an Attachment
// IMPORTANT- Browser Determines How to Handle Attachments:
// IE may present Save Dialog Box
// Chrome does not present Save Dialog Box, only immedate download of file.
string mimeType = MimeMapping.GetMimeMapping(fileName);
if (!streamRawFile)
{
Response.AppendHeader("Content-Disposition", "attachment; filename="" + fileName + """);
Response.AppendHeader("X-Download-Options", "noopen");
}
return File(stream, mimeType);
} else
{
return nullResponse;
}
}
Note that in the highlighted line of code surrounding the filename with double-quotes works fine for other special characters ($, #, @, &, etc) but equal signs are stripped out.
Is there something special I have to do, some way to escape the equal sign to make sure the downloaded file name retains the equal sign?
Thanks,
Brad
---------------------------------------------
protected FileStreamResult StreamFileToHttpResponse(Stream stream, string fileName, bool streamRawFile = false)
{
FileStreamResult nullResponse = null;
if (stream != null && !string.IsNullOrEmpty(fileName))
{
//Identify MimeType and Return to Browser as an Attachment
// IMPORTANT- Browser Determines How to Handle Attachments:
// IE may present Save Dialog Box
// Chrome does not present Save Dialog Box, only immedate download of file.
string mimeType = MimeMapping.GetMimeMapping(fileName);
if (!streamRawFile)
{
Response.AppendHeader("Content-Disposition", "attachment; filename="" + fileName + """);
Response.AppendHeader("X-Download-Options", "noopen");
}
return File(stream, mimeType);
} else
{
return nullResponse;
}
}