I ran into this weird thing. Im trying to avoid adding the whole code as its long and kinda private but the issue is:
// string has no white spaces:
string fileName = "noWhiteSpacesHere" + ".pdf";
response.StatusCode = HttpStatusCode.OK;
response.Content = new ByteArrayContent(fileData);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") {FileName = fileName };
// ContentDispositionHeaderValue("attachment") = "noWhiteSpacesHere.pdf"
but in contrast:
// string has white spaces:
string fileName = "some white spaces" + ".pdf";
response.StatusCode = HttpStatusCode.OK;
response.Content = new ByteArrayContent(fileData);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") {FileName = fileName };
// ContentDispositionHeaderValue("attachment") = "\"some white spaces.pdf\""
**
- note the extra quotation marks on the second example.
- when i check the "fileName" parameter it does not show these extra quotation marks and they appear only in the content disposition header.
- white spaces should be supported. i cant trim/replace etc.
**
i hope this is enough. do u guys know the reason? how can i stop this?
if any code is crucially missing let me know.
thanks!