473,320 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ServerProtocolViolation after HttpWebRequest.GetResponse()

I have a strange behavior of a following code:

HttpWebRequest
request=(HttpWebRequest)WebRequest.Create(@"http://.../target.jsp");
request.ProtocolVersion=HttpVersion.Version11;
request.Method="POST";
request.ContentType="text/plain";
request.KeepAlive = true;
request.ContentLength=data.Length;
try
{
Stream newStream=request.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();
HttpWebResponse response=(HttpWebResponse)request.GetResponse();
//Exception here
...
}
catch
{

}

After GetResponse is called I receive exception with Status =
WebExceptionStatus.ServerProtocolViolation.

I used sniffer to scan which requests/reponses are being handled during this
operation from IE and from my code - all of requests/responses are the
same - response is HTTP 200 OK for both ways of request.

Does anybody can shed a light why .Net Framework returns such an exception
even if response status is OK?
Nov 19 '05 #1
1 3013
<no***@west100.com> wrote:
I have a strange behavior of a following code:

HttpWebRequest
request=(HttpWebRequest)WebRequest.Create(@"http://.../target.jsp");
request.ProtocolVersion=HttpVersion.Version11;
request.Method="POST";
request.ContentType="text/plain";
request.KeepAlive = true;
request.ContentLength=data.Length;
try
{
Stream newStream=request.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();
HttpWebResponse response=(HttpWebResponse)request.GetResponse();
//Exception here
...
}
catch
{

}

After GetResponse is called I receive exception with Status =
WebExceptionStatus.ServerProtocolViolation.

I used sniffer to scan which requests/reponses are being handled
during this operation from IE and from my code - all of
requests/responses are the same - response is HTTP 200 OK for both
ways of request.

Does anybody can shed a light why .Net Framework returns such an
exception even if response status is OK?


Your code sample isn't suspicious (the fact that you post text/plain
content is a conscious choice, isn't it?).

Can you post a HTTP trace?

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #2

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

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
1
by: Jeff B | last post by:
I'm trying to create a simple screen scraping application and I kept getting a System.Net.WebException thrown back with a message of "The operation has timed-out." At first I thought it was some...
2
by: Steve Richter | last post by:
I have a page that uses simple HTTP GET to do an ISBN lookup via Amazon.com. The page works when I run it from //localhost. But I have moved it to my godaddy.com shared hoster site, and I get...
2
by: GlennLanier | last post by:
Hello, I've searched the forums and can't find an answer -- if it i there, kindly point me in that direction. I would like to simulate a browser POSTing a FORM and be able to pars the response....
1
by: Joe | last post by:
I'm creating an application that HTTP posts some form data, and is supposed to read the response. When I actually do this form posting from a web page, I get the response exactly as I would...
5
by: mr.newsgroupguy | last post by:
I am working in C# .NET 1.1. My app has a button on its main form that checks to see if it has access to a file on our server, just an XML file. On our server we are running W2K IIS with a...
7
by: Marc Bartsch | last post by:
Hi, I have a background worker in my C# app that makes a synchronous HttpWebRequest.GetResponse() call. The idea is to POST a file to a server on the internet. When I call HttpWebRequest.Abort()...
1
by: ALA | last post by:
Hi, does anybody know if it is possible to pass the SessionID with a web request by using a cookie so that the invoked page in the same domain can access the session objects of the current user?...
4
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi, I've run into a set of errors I don't understand coming back from HttpWebRequest.GetResponse, In one case, null is returned from the request without an Exception and in the other the request...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.