views:

28

answers:

0

So I've got this chunk of code in an ASP.net MCV2 View, which is making a computer dude read some data. I'm doing this to integrate with an IVR system, and I want the IVR to be able to pretend the .wav file is a remote resource, like: http://servername/Account/12345/Balance.wav

 SpVoice speech = new SpVoice();
 SpeechStreamFileMode SpFileMode = 
 SpeechStreamFileMode.SSFMCreateForWrite;
 SpFileStream SpFileStream = new SpFileStream();

 string filename = Guid.NewGuid().ToString() + ".wav";
 string fullpath = @"C:\Dev\CoreData\Mvc2Browser\Content\" + filename;

 Response.ClearContent();

 Response.ClearHeaders();

 Response.ContentType = "audio/wav";
 Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
 SpFileStream.Open(fullpath, SpFileMode, false);
 speech.AudioOutputStream = SpFileStream;
 speech.Rate = 0;
 speech.Volume = 50;
 speech.Speak(itemSummary, SpeechVoiceSpeakFlags.SVSFlagsAsync);
 speech.WaitUntilDone(20000);
 SpFileStream.Close();

 Response.TransmitFile(fullpath);

The file is created and downloads fine, but it refuses to open in Media Player, claiming it is not compressed properly or I don't have the codec. It's also about 40% larger than the server copy. If I launch the file locally, from my dev server's directory, it opens and plays fine.

I have already added

    <authorization>
      <allow users="*"/>
    </authorization>

to web.config in a fit of desperation, and have tried Response.Redirecting to the file (which makes MVC attempt to find a Controller, which it does not). I feel like I can do this without some kind of new controller/routing situation, but I'm stuck.

Any help would be appreciated.