473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

The server committed a protocol violation. Section=ResponseStatusLine

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.netto 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().GetResponseSt ream().

Any ideas? I have run out of my own.
Jan 30 '07 #1
3 13701
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" wrote:
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.netto 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().GetResponseSt ream().

Any ideas? I have run out of my own.
Jan 30 '07 #2
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 [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:64**********************************@microsof t.com...
>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" wrote:
>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.netto 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().GetResponseS tream().

Any ideas? I have run out of my own.

Jan 30 '07 #3
In article <64**********************************@microsoft.co m>,
pb*******@yahoo.yabbadabbadoo.com says...
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?
Feb 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Colin Crossman | last post by:
So, I'm trying to write a web spider for some data gathering from a public database webserver. Anyway, in response to a POST, the webserver returns "200 Script Results Follow" instead of "201...
1
by: piotrek | last post by:
Hi. I have problem : The server committed a protocol violation. Section=ResponseStatusLine - exeption. in code: ...
4
by: objectref | last post by:
Hi, does anybody have found a working solution for this HttpRequest error : "ServerProtocolViolation/The server committed a protocol violation. Section=ResponseStatusLine" i tried the...
0
by: Kris Mattheus | last post by:
A little background: I've been using web services successfully for a while now. My web server is a Windows CE 4.2 device and my client is a windows C# application created with Visual Studio 2003....
3
by: Scott McDermott | last post by:
I have an application that is making an HTTP request with HttpWebRequest.GetRequest. Unless I set 'httpWebRequest useUnsafeHeaderParsing="true"' in the web.config, I get a 'The server committed a...
0
by: Marcus Ogden | last post by:
Hello, A client of ours using the Squid proxy server (version 2.5.STABLE6-3.4E.12.1) on Red Hat Enterprise Linux 4 is experiencing a problem when running our .NET 2.0 client application, which...
0
by: Edwardseok | last post by:
Hello All, I am making VB.NET application program to read data from other equipment. The following is my code.(VB2005.NET) ---------------code -------------------------- Private Sub...
0
by: oriol.ardevol | last post by:
Hi, I have an asp.net application that connects through an HttpWebRequest object to a ISAPI dll in a server. This isapi dll has some different method calls. What I do is calling the different...
16
Kevinyy
by: Kevinyy | last post by:
Here is my code snippet: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.KeepAlive = true; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //The...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.