开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜