2

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?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Douglas
  • 36,802
  • 9
  • 76
  • 89

3 Answers3

3

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

Sky Sanders
  • 36,396
  • 8
  • 69
  • 90
  • Hi, will try out CassiniDev - I didn't see any obvious links on whether I could use it as a drop in replacement - will have to google some more. WRT your problem, I've found that just copying in NPWPF.dll, either into the FF plugins directory or "C:\Windows\Microsoft.NET\Framework\v3.5\Windows Presentation Foundation" gets it going again. We had this problem when upgrading to Windows 7 machines. – Douglas May 18 '10 at 16:09
  • @douglas - i just released the visual studio replacement - http://skysanders.net/subtext/archive/2010/05/22/release-cassinidev-for-visual-studio-2008-a-drop-in.aspx - give it a shot and leave a review/feed back on the codeplex site. – Sky Sanders May 22 '10 at 18:06
  • I'm now using CassiniDev for this, and it's working perfectly. – Douglas Jul 31 '10 at 14:46
  • @douglas- glad to hear that it is working well for you. I like it too.;-) – Sky Sanders Aug 01 '10 at 02:07
  • Does CassiniDev support the `` settings in the `` section in the web.config? – travis Nov 21 '12 at 17:24
  • 1
    @travis - i really can't say without writing some tests. perhaps this is something you can verify. – Sky Sanders Dec 15 '12 at 15:20
1

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.

G.Y
  • 6,042
  • 2
  • 37
  • 54
0

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

Alex
  • 721
  • 6
  • 11