我想将 xbaps 从 VS Web 开发服务器(cassini)提供给 Firefox,但是当从开发服务器提供时,Firefox 提供下载此文件。据我所知,这是因为开发服务器正在为 xbap 文件提供 mime 类型的“application/octet-stream”而不是“application/x-ms-xbap”,后者在从 IIS 提供时有效。
有谁知道如何更改开发服务器用于 *.xbap 文件的 mime 类型?
我想将 xbaps 从 VS Web 开发服务器(cassini)提供给 Firefox,但是当从开发服务器提供时,Firefox 提供下载此文件。据我所知,这是因为开发服务器正在为 xbap 文件提供 mime 类型的“application/octet-stream”而不是“application/x-ms-xbap”,后者在从 IIS 提供时有效。
有谁知道如何更改开发服务器用于 *.xbap 文件的 mime 类型?
你不能。WevDev.WebHost 在发布内容类型时相当笨拙,并且特定内容类型的范围非常有限。
您可以使用CassiniDev。最新版本提供了扩展的内容类型支持,包括 .xbap。
有关受支持类型的完整列表,请参阅http://cassinidev.codeplex.com/SourceControl/changeset/view/49870#894160 。
更新:您的问题可能是您在 3.5sp1 之后安装了 FF,并且NPWPF.dll
您的 FF 插件目录中没有。你有这个文件吗?
更新 2 我刚刚发布了一个 CassiniDev 版本,它可以很好地替代 Visual Studio 的开发服务器。它的增强功能包括改进的内容类型支持和集成的流量记录/查看。
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.
请注意,使用 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