views:

31

answers:

2

I'm just trying to sent a .wav file to Internet Explorer with an ASP.net Handler:

public void ProcessRequest(HttpContext context)
{
    HttpResponse response = context.Response;
    response.ContentType = "audio/x-wav";
    response.WriteFile("MyWav.wav");
    response.AddHeader("Content-Length", "304578");

    response.Flush();
}

This works for Firefox and Chrome but I'm just presented with a blank screen in Internet Explorer. Why?

(I've tried setting the "Content-Disposition" header. If I set it to "attachment" I am presented with the download dialog. If I set it to "inline", I just get a blank page like before.

+1  A: 

You can try to embed it in an object

<object
classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="AutoStart" value="1" />
<param name="FileName" value="GiveYourPageNameHere.aspx" />
</object>

The page that sends the wav file to the browser can also act as the source as i've mentioned in the example above or you can directly specify the filename.

Ritik Khatwani
That works for IE but requires the installation of a plug-in for Firefox and Chrome. I don't understand why IE is having issues with my ASP.net page when it's fine with others e.g. http://www.nch.com.au/acm/11k16bitpcm.wav
A: 

It turns out that IE tries to be clever and ignores the HTTP headers and if there isn't .wav in the URL it assumes it's text.

This was confirmed by setting up an alias URL /foo/bar.wav?audioId=123 to point to /foo/baz?audioId=123. When accessed directly nothing is displayed in IE, but when accessed via the alias it displays and plays the .wav file.

Thanks Microsoft, thanks.