HTTP request & HTTP protocol violation

G

Guest

Hi,

I am trying to read some industrial webservers using the HTTP/CGI webequest
like this:

wrs = (HttpWebRequest)WebRequest.Create(HTTP/CGI-string);
mwst = (HttpWebResponse wrs.GetResponse();
str = mwst.GetResponseStream();

This usually works fine but on some servers i get:
"System.Net.WebException: The underlying connection was closed: The server
committed an HTTP protocol violation."

The same request works fine in IE and basically i just want whatever comes
from the server to parse it...

So how can i get around this http protocol violation and stille get the data
from the server ? - Is there some alternative (- and less sensitive) way to
do a CGi request ?
 
J

John Timney \(ASP.NET MVP\)

When you say it works from a browser - are you doing a post or a get
request. Try forcing a post request through and see if that works from the
net code.

Also, I assume that this (HTTP/CGI-string) is a quoted address string as its
not in your example.
--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
N

Nicholas Paldino [.NET/C# MVP]

Henrik,

Are there cookies perhaps on the browser that are being passed to the
server? Also, does the server do anything based on the user agent string
that is sent to the server? Do you have to set up a proxy for the browser
(which would indicate you have to set up a proxy for the WebRequest as
well)?

The server can do a number of things, based on a number of different
parameters other than just the URL string.

Hope this helps.
 
J

Joerg Jooss

Henrik said:
The http request is a string like
"http://IP/cgi/command.cgi?blablabla" and as said it works fine in a
browser...

When i add the POST method i just get this:
System.Net.WebException: The operation has timed-out.

You cannot just simply change the method to POST. Posting requires data
being written to the request stream. If not, the operation will time out, as
you've seen.


Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top