Content Type Problem in Internet Explorer 7
This codes forces Google Chrome to download the file as .aspx
and for IE7 as .htm
Dim sFileString As String = HttpContext.Current.Request("FileString")
If Not String.IsNullOrEmpty(sFileString) Then
Dim bBuffer() As Byte = System.Text.Encoding.ASCII.GetBytes(sFileString)
Response.ClearContent()
Response.ContentType = "application/text"
Response.ClearHeaders()
Response.AddHeader("Content-Disposition", "attachment")
Response.AddHeader("Filename", "ACHFile.txt")
Response.OutputStr开发者_运维知识库eam.Write(bBuffer, 0, bBuffer.Length)
End If
I want it to download the file as .txt
but didn't make it.
I believe you should use text/plain
See:
MIME Type Detection in Internet Explorer
http://msdn.microsoft.com/en-us/library/ms775147(v=vs.85).aspx
How To Raise a "File Download" Dialog Box for a Known MIME Type http://support.microsoft.com/kb/260519
Update:
Also try
Response.AppendHeader("Content-Type", "application/force-download;");
精彩评论