HttpWebRequest.GetResponse() Querystring length problem

G

Guest

I found a weird behavior of HttpWebRequest.GetResponse() in WM5

It raises exception if length of URL is around 2150. And also sends the data
to server successfully. Therefore, there is no way to detect that the data is
successfully received at server or not.

The error message is “Could not establish connection to network.†whereas
connection is completely ok.

The same code runs well from desktop application. I just copy past it there.

(In this code below I just modify the URL to google.com that's why if it
will work then there will be a web exception for error 400 range not the
connection error; so don't worry for 400 exception.)



string URL = new String('x', 2500);
URL = "http://www.google.com/" + URL;
URL = URL.Substring(0, 2084); // 2083 works great
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //
exception!!!
StreamReader reader = new StreamReader(response.GetResponseStream(),
Encoding.UTF8);

string result = reader.ReadToEnd();
MessageBox.Show(result);

Any idea how I can send a larger string specifically using “GETS". I just
chage it to POST but it was also not working for this url
 
F

Fred Chateau

Kamii47 said:
I found a weird behavior of HttpWebRequest.GetResponse() in WM5
It raises exception if length of URL is around 2150. And also sends the
data
to server successfully. Therefore, there is no way to detect that the data
is
successfully received at server or not.

I believe that is a function of IIS, which limits the size of GET URL's for
security purposes. I also don't think your entire GET request is making it
to the server. That's where your exception is originating.

I suggest you use a POST request or do a search on communicating with the
server using Script tags from Javascript.
 
G

Guest

Can i have a example of that ?

Fred Chateau said:
I believe that is a function of IIS, which limits the size of GET URL's for
security purposes. I also don't think your entire GET request is making it
to the server. That's where your exception is originating.

I suggest you use a POST request or do a search on communicating with the
server using Script tags from Javascript.

--
Regards,

Fred Chateau
fchateauAtComcastDotNet
 

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