使用 VS Web Dev Server 覆盖 mime 类型

发布于 2024-09-01 15:19:35 字数 234 浏览 5 评论 0原文

我想从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

傲影 2024-09-08 15:19:36

请注意,通过 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

情独悲 2024-09-08 15:19:35

你不能。 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

百变从容 2024-09-08 15:19:35

现在可能已经太晚了,但对于其他遇到这个问题的人来说,如何解决它:

我为 mp4 视频解决了这个问题,但这对于任何 mime 来说都是相同的原理,
只需根据您的需求进行修改即可。

我假设您使用 vs2012,创建 IHttpHandler 并将此代码复制到其中:

public class Mp4Handler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "video/mp4";
        context.Response.BinaryWrite(File.ReadAllBytes(context.request.PhysicalPath));
        context.Response.End();
    }

public bool IsReusable{ get{ return false;}}
}

并记住添加到 system.web 下的 web.config 文件:

<httpHandlers>
    <add verb="*" path="*.mp4" type="[your-namespace].Mp4Handler" />
</httpHandlers>

通过这样做,您将不再需要 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:

public class Mp4Handler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "video/mp4";
        context.Response.BinaryWrite(File.ReadAllBytes(context.request.PhysicalPath));
        context.Response.End();
    }

public bool IsReusable{ get{ return false;}}
}

And remember to add to your web.config file under system.web:

<httpHandlers>
    <add verb="*" path="*.mp4" type="[your-namespace].Mp4Handler" />
</httpHandlers>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文