Re: problem with HttpWebRequest GetResponse
- From: "Kevin Spencer" <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 11 May 2006 18:17:55 -0400
It is possible that the server is actually sending an illegal HTTP response.
This happens with some servers. You can change a configuration setting in
the system.net configuration section (httpWebRequest element) like so, to
allow unsafe header parsing:
<configuration>
<system.net>
<settings>
<httpWebRequest
useUnsafeHeaderParsing="true"
/>
</settings>
</system.net>
</configuration>
It may fix the problem.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"Kevin Spencer" <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:efP%23IiSdGHA.3840@xxxxxxxxxxxxxxxxxxxxxxx
What exactly is in "data"? I know it's in byte array format, but what is
it in string format?
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"bg" <bg@xxxxxx> wrote in message
news:O2RGvRSdGHA.3348@xxxxxxxxxxxxxxxxxxxxxxx
Hi all.
I 'm trying to automate some of my workflow, by doing some programmatic
"POST"s to an internal webserver via HttpWebRequest. The Code is your
usual straight forward type of thing.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType="application/x-www-form-urlencoded";
req.ContentLength = data.Length;
Stream newStream=req.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();
reponse = req.GetResponse() as HttpWebResponse; <===goes bang here
But on the GetResponse I get an "The underlying connection was closed:
The server committed an HTTP protocol violation." exception.
Now the thing is if I use the excellent TcpTrace utility to trace whats
going over and coming back I can see that valid data is being retrieved
from the call, So how can I ignore the exception and just get to the
response data? (HaveResponse is true, but response ==null)
Or perhaps there's a flag i'm not setting somewhere?
TIA.
bg
.
- Follow-Ups:
- References:
- problem with HttpWebRequest GetResponse
- From: bg
- Re: problem with HttpWebRequest GetResponse
- From: Kevin Spencer
- problem with HttpWebRequest GetResponse
- Prev by Date: Re: 2.0: "Page cannot be refreshed without sending information again."
- Next by Date: Re: error in exporting Crystal Report in ASP.net - URGENT
- Previous by thread: Re: problem with HttpWebRequest GetResponse
- Next by thread: Re: problem with HttpWebRequest GetResponse
- Index(es):
Relevant Pages
|