S
sstreaker
I'm serving an MP3 file via a BinaryWrite from an ASPX file. If I have
Content-Disposition set to "inline", WMP opens as expected but hits my
ASPX page 3 times and then finally play the file. This is not
desirable because the impact on the server is idential to that if 3
different clients hit the same page.
If I have Content-Disposition set to "attachment", IE prompts with
Save/Open as expected, and if I choose save, the ASPX page is hit only
once and the MP3 is successfully saved and playable, as expected.
Analysis of the data being streamed to the browser indicates that the
MP3 file is encoded properly, complete, and playable by WMP.
Based on these observations, I can only assume at this point that my
server-side code is correct as far as how I am writing the file to the
response stream.
So, why is WMP hitting my page more than once? What is it looking for?
Code is pretty straight-foward and follows. Thanks in advance! =)
-----------------
Response.ContentType = "audio/mpeg";
Response.Buffer = true;
Response.BufferOutput = true;
char[] chars = new char[4096];
int i;
// FYI mystringreader is a placeholder for Process.StandardOutput,
// which is the source of the data
while((i=mystringreader.Read(chars,0,chars.Length))>0) {
Response.BinaryWrite(Encoding.Default.GetBytes(chars));
Response.Flush();
}
Content-Disposition set to "inline", WMP opens as expected but hits my
ASPX page 3 times and then finally play the file. This is not
desirable because the impact on the server is idential to that if 3
different clients hit the same page.
If I have Content-Disposition set to "attachment", IE prompts with
Save/Open as expected, and if I choose save, the ASPX page is hit only
once and the MP3 is successfully saved and playable, as expected.
Analysis of the data being streamed to the browser indicates that the
MP3 file is encoded properly, complete, and playable by WMP.
Based on these observations, I can only assume at this point that my
server-side code is correct as far as how I am writing the file to the
response stream.
So, why is WMP hitting my page more than once? What is it looking for?
Code is pretty straight-foward and follows. Thanks in advance! =)
-----------------
Response.ContentType = "audio/mpeg";
Response.Buffer = true;
Response.BufferOutput = true;
char[] chars = new char[4096];
int i;
// FYI mystringreader is a placeholder for Process.StandardOutput,
// which is the source of the data
while((i=mystringreader.Read(chars,0,chars.Length))>0) {
Response.BinaryWrite(Encoding.Default.GetBytes(chars));
Response.Flush();
}