ASP.NET Filename encoding while sending file
asp.net, encoding
Solution
Put the file name in quotes:-
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
Problem
I am sending a file from ASP.NET Page to the browser. To properly send a filename I am adding a header: ``` Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + filename); ``` The problem is that when file contains white spaces (e.g. "abc def") browser receives only "abc" part of the filename. I have tried with: Server.HtmlEncode but it didn't help. Do you have any idea how to solve this problem? PK