473,320 Members | 1,859 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.

System.Net.WebClient HTTP Protocol Error

I am using the System.Net.Webclient to try and download an
XML file from a website but am receiving a HTTP protocol
error when running the DownloadFile() sub routine. I did
a HTTP trace using internet explorer to see what is
happening in the request and it looks as though the
request originates using HTTP/1.1 to an IIS server
authenticates itself but ultimately gets executed by a
Java Application server and when the request is fulfilled
it returns "HTTP/1.0" I'm assuming this is probably
against the HTTP spec and is what is generating the
protocol error? Is there any workaround to this using the
Webclient or am I going to have to approach the problem at
a sockets level, and if so does anyone have a HTTP sockets
client out there that is not the WebClient?

Internet explorer seems to have no problem dealing with
the request and it returns fine in the browser, but when
going at it using the WebClient it errors out.

Here is the request response information for the request
which shows the different protocol versions:
Server Information
IP Address: 192.251.14.15:443
Response Time: 00:00:02.304
Client Request
3 GET /mkt/xml/private/XmlRequest?
request=GENBYPARTICIPANT&DAY=20031007 HTTP/1.1
Header Contents
HTTP/1.0 200 OK

Note:This is only the final request, there are previous
requests which show a 401 denied and it then
authenticates, all using HTTP/1.1 its only the final
request that returns HTTP/1.0
Jul 21 '05 #1
4 15353
I thought I would include some more information to go over. Here is the
exact error that is received:

An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The underlying connection was closed: The server
committed an HTTP protocol violation.
This is the code that is generating the error:

Dim myclient As New System.Net.WebClient
Dim mycli As New System.Net.WebPermission

myclient.QueryString = New
System.Collections.Specialized.NameValueCollection

myclient.QueryString.Add("request", "GENBYPARTICIPANT")

myclient.QueryString.Add("DAY", "20031008")

myclient.Credentials = New System.Net.NetworkCredential("USERID",
"PASSWORDS")

myclient.DownloadData("https://xxxxx.xxxxx.com/mkt/xml/private/XmlRequest")
Jul 21 '05 #2
Maybe try WebRequest (not WebClient) ?

System.Net.WebRequest req= System.Net.WebRequest.Create(urlspec);
System.IO.StreamReader sr = new System.IO.StreamReader
(req.GetResponse().GetResponseStream());
result= sr.ReadToEnd ();

The urlspec should be
http://foo.bar/xml/something/fribble...T&DAY=20031008

if you want a credential then you need to do

request.Credentials = System.Net.CredentialCache.DefaultCredentials;

or something similar.

-D

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m
"Justin Malloy" <ju****@nrgonline.com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
I thought I would include some more information to go over. Here is the
exact error that is received:

An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The underlying connection was closed: The server
committed an HTTP protocol violation.
This is the code that is generating the error:

Dim myclient As New System.Net.WebClient
Dim mycli As New System.Net.WebPermission

myclient.QueryString = New
System.Collections.Specialized.NameValueCollection

myclient.QueryString.Add("request", "GENBYPARTICIPANT")

myclient.QueryString.Add("DAY", "20031008")

myclient.Credentials = New System.Net.NetworkCredential("USERID",
"PASSWORDS")

myclient.DownloadData("https://xxxxx.xxxxx.com/mkt/xml/private/XmlRequest")

Jul 21 '05 #3
Under the covers I believe WebClient is doing the exact same thing, it uses
WebRequest to issue its request. At any rate, I converted the code over to
use WebRequest and the same error was generated when the request went out to
the server. I know its not a problem with authentication because I can
issue an incorrect userid and the server returns me an XML document that
states my userid is incorrect. The odd part is that the authentication
error returns HTTP/1.1 --- which goes back to my original problem where the
final valid request returns HTTP/1.0 which I would guess is causing the
error. I guess I have no problem opening up a phone support incident if
you think this is something they would be able to help me with?


"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:uI**************@TK2MSFTNGP09.phx.gbl...
Maybe try WebRequest (not WebClient) ?

System.Net.WebRequest req= System.Net.WebRequest.Create(urlspec);
System.IO.StreamReader sr = new System.IO.StreamReader
(req.GetResponse().GetResponseStream());
result= sr.ReadToEnd ();

The urlspec should be
http://foo.bar/xml/something/fribble...T&DAY=20031008

if you want a credential then you need to do

request.Credentials = System.Net.CredentialCache.DefaultCredentials;

or something similar.

-D

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m
"Justin Malloy" <ju****@nrgonline.com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
I thought I would include some more information to go over. Here is the
exact error that is received:

An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The underlying connection was closed: The server
committed an HTTP protocol violation.
This is the code that is generating the error:

Dim myclient As New System.Net.WebClient
Dim mycli As New System.Net.WebPermission

myclient.QueryString = New
System.Collections.Specialized.NameValueCollection

myclient.QueryString.Add("request", "GENBYPARTICIPANT")

myclient.QueryString.Add("DAY", "20031008")

myclient.Credentials = New System.Net.NetworkCredential("USERID",
"PASSWORDS")

myclient.DownloadData("https://xxxxx.xxxxx.com/mkt/xml/private/XmlRequest")


Jul 21 '05 #4
Hello Justin,

Due to the nature of this issue, I would highly recommend you contact
Microsoft Product Support Services since it would require intensive
troubleshooting which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional.

Microsoft support home page: http://support.microsoft.com.

To view support options:
http://support.microsoft.com/default...d=sz;en-us;top.

To submit an online request:
http://support.microsoft.com/default...incidentsubmit.

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5

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

Similar topics

11
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred...
1
by: ATS | last post by:
ERR - WebClient.DownloadData returns "protocol violation" Please help, I'm getting a "protocol violation" from a site that is working perfectly fine when I issue WebClient.DownloadData as...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
1
by: Crirus | last post by:
Hello! Last year I used Framework's 1.0 WebControl to connect to a server designed by me with sockets and TCP. The client run in a html as activex. Right now, I reactivated that project... server...
0
by: MattB | last post by:
Hi, I'm trying to write a simple utility using vb.net that finds my DSL modem's external IP address via it's status page. It seemed simple at first, and I used an example I found online to come up...
4
by: Justin Malloy | last post by:
I am using the System.Net.Webclient to try and download an XML file from a website but am receiving a HTTP protocol error when running the DownloadFile() sub routine. I did a HTTP trace using...
6
by: | last post by:
I've written a very small ASP.NET page to scrape thousands of pages of content based on database IDs. It loops through a dataset to get the IDs. It worked well in testing but now I am getting an...
1
by: Mike | last post by:
I am using PowerShell to download an XML file into a string using the DownloadString(URI) method of System.Net.WebClient object. Sample commands below: $Result = $Null; $WebClient = new-object...
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
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...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.