扩展名为 .msg 的文件未下载
File with .msg extension not downloading
我有以下代码:
Dim filePath As String = Request.QueryString("FilePath")
Dim fileName As String = filePath.Substring(filePath.LastIndexOf("/") + 1)
Dim ext As String = Path.GetExtension(fileName)
'If (ext = ".xls") Then
' Response.ContentType = "application/vnd.ms-excel"
'ElseIf (ext = ".xlsx") Then
' Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
'End If
If ext = ".msg" Then
Response.ContentType = "application/octet-stream"
'Response.ContentType = "application/vnd.ms-outlook"
ElseIf (ext = ".xls") Then
Response.ContentType = "application/vnd.ms-excel"
ElseIf (ext = ".xlsx") Then
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
End If
'fileName = Server.MapPath("~\files\RAP_Batch_Upload_form.xls")
Response.AppendHeader("Content-Disposition", "attachment;filename=" & fileName)
'Response.AddHeader("Content-Length", New System.IO.FileInfo(fileName).Length)
'Response.AddHeader("Content-Length", New System.IO.FileInfo("Batch_test_11.xlsx").Length)
Response.Redirect(filePath)
Response.End()
我可以下载带有 .xls 和 .xlsx 文件的文件,但是 .msg 文件会出现找不到页面的错误。这些文件存储在附件文件夹中,示例文件路径看起来像 http://our.domain.com/Attachment/2017123456 Demo_Re.msg(Space 是文件名的一部分,对于 .xls 和 .xlsx 文件来说这不是问题)。
谁能告诉我我错过了什么。
打开您的 IIS,select 网站属性
Select HTTP Header -> 单击 MIME 类型 -> 单击新建并添加“.msg”作为扩展名和 "application/vsd.ms-outlook" 作为 MIME 类型。
我有以下代码:
Dim filePath As String = Request.QueryString("FilePath")
Dim fileName As String = filePath.Substring(filePath.LastIndexOf("/") + 1)
Dim ext As String = Path.GetExtension(fileName)
'If (ext = ".xls") Then
' Response.ContentType = "application/vnd.ms-excel"
'ElseIf (ext = ".xlsx") Then
' Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
'End If
If ext = ".msg" Then
Response.ContentType = "application/octet-stream"
'Response.ContentType = "application/vnd.ms-outlook"
ElseIf (ext = ".xls") Then
Response.ContentType = "application/vnd.ms-excel"
ElseIf (ext = ".xlsx") Then
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
End If
'fileName = Server.MapPath("~\files\RAP_Batch_Upload_form.xls")
Response.AppendHeader("Content-Disposition", "attachment;filename=" & fileName)
'Response.AddHeader("Content-Length", New System.IO.FileInfo(fileName).Length)
'Response.AddHeader("Content-Length", New System.IO.FileInfo("Batch_test_11.xlsx").Length)
Response.Redirect(filePath)
Response.End()
我可以下载带有 .xls 和 .xlsx 文件的文件,但是 .msg 文件会出现找不到页面的错误。这些文件存储在附件文件夹中,示例文件路径看起来像 http://our.domain.com/Attachment/2017123456 Demo_Re.msg(Space 是文件名的一部分,对于 .xls 和 .xlsx 文件来说这不是问题)。
谁能告诉我我错过了什么。
打开您的 IIS,select 网站属性
Select HTTP Header -> 单击 MIME 类型 -> 单击新建并添加“.msg”作为扩展名和 "application/vsd.ms-outlook" 作为 MIME 类型。