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.Cre ate(url);
req.Method = "POST";
req.ContentType ="applicatio n/x-www-form-urlencoded";
req.ContentLeng th = data.Length;
Stream newStream=req.G etRequestStream ();
newStream.Write (data,0,data.Le ngth);
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 2378
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******** ******@TK2MSFTN GP03.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.Cre ate(url); req.Method = "POST"; req.ContentType ="applicatio n/x-www-form-urlencoded"; req.ContentLeng th = data.Length; Stream newStream=req.G etRequestStream (); newStream.Write (data,0,data.Le ngth); 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***@DIESPAMM ERSDIEtakempis. 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=valu e.....
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:
<configuratio n>
<system.net>
<settings>
<httpWebReque st
useUnsafeHeader Parsing="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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ef******** ********@TK2MSF TNGP04.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******** ******@TK2MSFTN GP03.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.Cre ate(url); req.Method = "POST"; req.ContentType ="applicatio n/x-www-form-urlencoded"; req.ContentLeng th = data.Length; Stream newStream=req.G etRequestStream (); newStream.Write (data,0,data.Le ngth); 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.Cre ate(url); req.Method = "POST"; req.ContentType ="applicatio n/x-www-form-urlencoded"; req.ContentLeng th = data.Length; Stream newStream=req.G etRequestStream (); newStream.Write (data,0,data.Le ngth); 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********@joer gjooss.de
Added "useUnsafeHeade rParsing="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 in a variable and make the request again with
that cookie as a header value (Digest Authentication).
But, the problem we are facing is: That the HttpWebRequest is getting two
responses simultaneously, which means that the code should wait after...
|
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 when the file is inside
a shared folder on my computer. If I try to upload from any other folder it
does not work. Why is this?
Reason being that whenever I upload files on other forums or websites I know
I don't need to have my folder shared...
|
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 in a variable and make the request again with that cookie as a header value (Digest Authentication).
But, the problem we are facing is: That the HttpWebRequest is getting two responses simultaneously, which means that the code should wait after the...
|
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
System.Net.WebException: The underlying connection was closed: The request
was canceled. ---> System.IO.IOException: Unable to read data from the
transport connection. ---> System.ObjectDisposedException: Cannot access a
disposed object named...
|
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")
Req.Method = "POST"
Req.AllowAutoRedirect = True
Req.Proxy = System.Net.WebProxy.GetDefaultProxy()
| |
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.
I have the following code in my Page_Load (litResponse is defined a
<ASP:Literal>):
|
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 the year. The page is
http://www.lotto.be/pages/show.aspx?Culture=nl&pageid=results/download/lotto
(in Dutch) or http://www.lotto.be/pages/show.aspx?Culture=en&pageid=results/download/lotto
(in English)
I want to write a Windows Service in...
|
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 System.Collections.Generic;
using System.ComponentModel;
using System.Data;
|
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 =
(HttpWebRequest)WebRequest.Create(url);
// set proxy
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |