Content-Type text/plain being ignored in IE based on file extension
I have a classic ASP page that is setting the ContentType to "text/plain" and streaming the bytes of a text file to the browser. However, Internet Explorer 7 (and presumably other versions) is ignoring this and instead of opening the darn text document in a monospaced font as it should it's prompting "Do you want to save or open this file?" because it's coming from a web page ending in ".asp".
When I set .txt files to be run through the ASP parser and then make a copy of my .asp page with the extension .txt, everything works fine.
I've examined the headers in Firebug on FF and know I'm setting the content-type correctly and not missing any other important headers.
Is there any other technique to preventing IE from using the f开发者_JS百科ile extension to change how it responds?
This is nonsense! Respect my content-type, you third-rate browser!
Try changing the filename (with extension) using the content disposition header
Something like Response.AddHeader("Content-Disposition", "inline;filename="File.txt") And you already said the content type header is being set correctly so that should do it.
精彩评论