使用 VS Web Dev Server 覆盖 mime 类型
我想从 VS Web 开发服务器(cassini)向 Firefox 提供 xbaps,但是当从开发服务器提供服务时,Firefox 会提供下载此文件。据我所知,这是因为开发服务器正在使用 mime 类型“application/octet-stream”而不是“application/x-ms-xbap”来提供 xbap 文件,后者在从 IIS 提供服务时有效。
有谁知道如何更改开发服务器用于 *.xbap 文件的 mime 类型?
I would like to serve xbaps from the VS web dev server (cassini) to Firefox, but when served from the dev server, Firefox offers to download this file. As far as I can tell, this is because the dev server is serving the xbap file with a mime type of "application/octet-stream" instead of "application/x-ms-xbap", which works when served from IIS.
Does anyone know how to change the mime type which the dev server uses for *.xbap files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请注意,通过 VS 2010 SP1,您现在可以在 Web 项目中使用 IIS Express 而不是 Cassini,这样您就可以完全控制 MIME 类型。
详细信息: http://blogs.msdn.com/b/webdevtools/archive/2011/03/14/enabling-iis-express-support-in-vs-2010-sp1.aspx
Note that with VS 2010 SP1, you can now use IIS Express instead of Cassini for your web projects, which gives you full control of your MIME types.
More information: http://blogs.msdn.com/b/webdevtools/archive/2011/03/14/enabling-iis-express-support-in-vs-2010-sp1.aspx
你不能。 WevDev.WebHost 在发布内容类型时相当笨拙,并且特定内容类型的范围非常有限。
您可以使用 CassiniDev。最新版本提供了扩展的内容类型支持,包括 .xbap。
请参阅http://cassinidev.codeplex.com/SourceControl/changeset/view/49870 #894160 了解受支持类型的完整列表。
更新:您的问题可能是您在3.5sp1之后安装了FF,并且FF插件目录中没有
NPWPF.dll
。你有这个文件吗?更新2
我刚刚发布了 CassiniDev 的一个版本,它是 Visual Studio 开发服务器的一个很好的替代品。它的增强功能包括改进的内容类型支持和集成的流量记录/查看。
http://skysanders.net/subtext/archive/2010/05/22/release-cassinidev-for-visual-studio-2008-a-drop-in.aspx
you can't. WevDev.WebHost is fairly clumsy when issuing content-types and has a very limited range of specific content-types.
You can use CassiniDev. The latest release provides extended content-type support, including .xbap.
see http://cassinidev.codeplex.com/SourceControl/changeset/view/49870#894160 for a complete list of supported types.
Update: your problem may be that you installed FF after 3.5sp1 and do not have the
NPWPF.dll
in your FF plugins directory. Do you have this file?Update 2
I have just released a version of CassiniDev that is a great drop in replacement for Visual Studio's Development server. It's enhancements include improved content-type support and integrated traffic logging/viewing.
http://skysanders.net/subtext/archive/2010/05/22/release-cassinidev-for-visual-studio-2008-a-drop-in.aspx
现在可能已经太晚了,但对于其他遇到这个问题的人来说,如何解决它:
我为 mp4 视频解决了这个问题,但这对于任何 mime 来说都是相同的原理,
只需根据您的需求进行修改即可。
我假设您使用 vs2012,创建 IHttpHandler 并将此代码复制到其中:
并记住添加到 system.web 下的 web.config 文件:
通过这样做,您将不再需要 CassiniDev 来正确地提供 mp4,但是,
CassiniDev 并不邪恶,值得保留 - 没有它我将无法首先验证问题所在。
It probably too late now, but for others who get that problem here is how to solve it:
I solved it for mp4 videos but it is the same principal for any mime,
just revise to your needs.
I assume you use vs2012, create IHttpHandler and copy this code into it:
And remember to add to your web.config file under system.web:
By doing so you will not need CassiniDev to serve mp4 correctly anymore, however,
CassiniDev is not evil and worth keeping - without it I wouldn't be able to verify what the problem was in the 1st place.