Get a file through Response without giving it an extension
I have an ASP.NET page where the user can click a but开发者_StackOverflow社区ton and get a file that don't have an extension.
string fileName = "ExtensionLessFileName";
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.Write("the text content of hte file");
Response.End();
The thing is that I need the downloaded file to be extension less but it seems to be impossible since the browser "save as" dialog forces me to make it a txt. I commented the ContentType line and the the file end up as an html.
I would appreciate your help to achieve this or to understand why it is not possible.
Try changing the MIME type. I suggest
Response.ContentType = "application/unknown";
It has worked for me for unknown file types.
精彩评论