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 5 2357
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@bg.com> wrote in message
news:O2**************@TK2MSFTNGP03.phx.gbl... 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
On 2006-05-11 19:27:16 +0100, "Kevin Spencer"
<ke***@DIESPAMMERSDIEtakempis.com> said: What exactly is in "data"? I know it's in byte array format, but what is it in string format?
its the name/value pairing stuff thats normally supplied by the form,
property1=value&property2=value.....
I took the data straight from a trace I had and still got the same exception.
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" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ef****************@TK2MSFTNGP04.phx.gbl... 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@bg.com> wrote in message news:O2**************@TK2MSFTNGP03.phx.gbl... 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
Thus wrote BG, 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)
Can you post a sample HTTP response? My usual answer is "fix the broken server"
;-)
Cheers,
--
Joerg Jooss ne********@joergjooss.de
Added "useUnsafeHeaderParsing="true"" to my app.config and it now works a
treat - thanks Kevin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Satinderpal Singh |
last post by:
Hi everyone,
We are using HttpWebRequest to create a request to a URI, which requires us
to login first. In order to process all the transactions, first we have to
login and get the cookie value...
|
by: R Reyes |
last post by:
I am trying to code a file uploader (for forum/email attachments) from the
client computer to a remote web server via the PUT method (since POST is not
allowed ). However, the upload works ONLY...
|
by: Satinderpal Singh |
last post by:
Hi everyone,
We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value...
|
by: japslam japslam via DotNetMonster.com |
last post by:
Hi all,
I have problem when I use HttpWebRequest and take long time to call to my
service server. If at that time there are many request comes in
semultaneous, I will get this exception
...
|
by: Taner Özyürekoglu |
last post by:
I have an error below. is there any idea about it.
Dim Req As HttpWebRequest =
WebRequest.Create("https://certification.authorize.net/gateway/transact.dll?"
& postdata)
Response.Write("3")...
|
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....
|
by: Veerle |
last post by:
Hi,
On the website of the Belgian lottery, you can download an excel sheet
with lottery results (the winning numbers) over the years and an excel
sheet with financial results (the winnings) over...
|
by: bliz_87 |
last post by:
Hello all, I'm trying to create a simple application that does a HTTP
request/response on a button click. Here's the entire code which I got
from a reference book:
using...
|
by: Georg |
last post by:
Hello,
I am trying to load a web page over a HTTP proxy with the POST method
and I am using the following code:
// open request (string url)
HttpWebRequest httpWebRequest =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
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...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
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...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |