Max*_*ion 11 c# asp.net outlook http-status-code-404
在我的应用程序中,我将一些文件保存在服务器上,并使它们可以在某些业务逻辑上下载.
所有其他文件类型都被下载但.msg(Outlook message)文件没有下载并给出错误:
404 - File or directory not found. The resource you are looking for might
have been removed, had its name changed, or is temporarily unavailable.
Run Code Online (Sandbox Code Playgroud)
图像,.docx,.txt所有其他文件都运行良好.
该页面是在ASP.NET和客户端站点上设计的.
Kar*_*ták 17
在ASP.NET 论坛上找到.
创建一个处理程序,将其下载为文件:
Response.ContentType = "application/vnd.ms-outlook";
Response.AppendHeader("Content-Disposition","attachment; filename=Message.msg");
Response.TransmitFile(Server.MapPath(YourPathToMsgFile));
Response.End();
Run Code Online (Sandbox Code Playgroud)
或更改IIS 6.0中的设置:
选择HTTP标头 - >单击MIME类型 - >单击新建,将".msg"添加为扩展名,将"application/vnd.ms-outlook"添加为MIME类型.
使用下面的这个标签,我们可以直接在标签中提及文件名。
<a href="Your File_Location">Download Link</a>
Run Code Online (Sandbox Code Playgroud)
无需在控制器中指定代码。
只需将以下标签添加到 web.config 里面
<staticContent>
<mimeMap fileExtension=".msg" mimeType="application/octet-stream" />
</staticContent>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9614 次 |
| 最近记录: |