The server committed a protocol violation. Section=ResponseStatusLine

A

Alon Albert

I have an ASP.NET that has an aspx that serves a binary file for download. I
need this rather than a direct link for various reasons.

I am getting the following error intermitently:

The server committed a protocol violation. Section=ResponseStatusLine

I tried adding:
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net> to the web.config file but made no difference.

I am using .NET 2.0.
The download client is also a .NET application.

The code that serves the file looks like this:

private void Page_Load(object sender, System.EventArgs e) {
string filename = Request["filename"];
string path = string.Format("c:/files/{0}", filename);

Response.ContentType = "APPLICATION/octet-stream";
Response.AddHeader("Content-Disposition",
string.Format("attachment;filename={0}", filename));
FileInfo fi = new FileInfo(path);
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.Flush();
Response.TransmitFile(path);
Response.End();
}

The client code reads from
WebRequest.Create(url).GetResponse().GetResponseStream().

Any ideas? I have run out of my own.
 
G

Guest

I think the problem may be the "attachment;" header. If you are using
WebRequest, what you really want to do is just stream out the data, not as an
"attachment".
Peter
 
A

Alon Albert

I'll give it a try. I think the reason I put that in was so that if I
download from a browser, it will prompt the proper filename rather than the
aspx page name. I think I found this in a an example somewhere. Is there
another way to do this? have the filename be prompted properly I mean?

Also, any idea why this would be happening intermittently?

Peter Bromberg said:
I think the problem may be the "attachment;" header. If you are using
WebRequest, what you really want to do is just stream out the data, not as
an
"attachment".
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Alon Albert said:
I have an ASP.NET that has an aspx that serves a binary file for
download. I
need this rather than a direct link for various reasons.

I am getting the following error intermitently:

The server committed a protocol violation. Section=ResponseStatusLine

I tried adding:
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net> to the web.config file but made no difference.

I am using .NET 2.0.
The download client is also a .NET application.

The code that serves the file looks like this:

private void Page_Load(object sender, System.EventArgs e) {
string filename = Request["filename"];
string path = string.Format("c:/files/{0}", filename);

Response.ContentType = "APPLICATION/octet-stream";
Response.AddHeader("Content-Disposition",
string.Format("attachment;filename={0}", filename));
FileInfo fi = new FileInfo(path);
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.Flush();
Response.TransmitFile(path);
Response.End();
}

The client code reads from
WebRequest.Create(url).GetResponse().GetResponseStream().

Any ideas? I have run out of my own.
 
A

Alon Albert

I think the problem may be the "attachment;" header. If you are using
WebRequest, what you really want to do is just stream out the data, not as an
"attachment".

Well, I removed the attachment code but it still happens. Any other
ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top