0
我有下面的代码:文件,扩展名的.msg不下载
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(空间是文件名的一部分,对于.xls和.xlsx文件不是问题)。
有人能告诉我我错过了什么。
好吧我需要将.msg添加到IIS,直到那时我不能正常工作?我应该只在IIS中添加它还是在web.config中添加 staticContent>是否足够? –
我只有通过IIS添加它,所以不能评论web.config。 – levis84
我的意思是application/vsd.ms-outlook。我添加到web.config。它不工作。我正在VS 2015 IIS Express中测试。 –