PC Review


Reply
Thread Tools Rate Thread

HttpWebRequest.GetResponse() Querystring length problem

 
 
=?Utf-8?B?S2FtaWk0Nw==?=
Guest
Posts: n/a
 
      2nd Nov 2007
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

 
Reply With Quote
 
 
 
 
Fred Chateau
Guest
Posts: n/a
 
      9th Nov 2007
"Kamii47" <(E-Mail Removed)> wrote ...

>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.

--
Regards,

Fred Chateau
fchateauAtComcastDotNet


 
Reply With Quote
 
=?Utf-8?B?S2FtaWk0Nw==?=
Guest
Posts: n/a
 
      10th Nov 2007
Can i have a example of that ?

"Fred Chateau" wrote:

> "Kamii47" <(E-Mail Removed)> wrote ...
>
> >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.
>
> --
> Regards,
>
> Fred Chateau
> fchateauAtComcastDotNet
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with HttpWebRequest GetResponse bg Microsoft ASP .NET 5 12th May 2006 11:20 AM
HttpWebRequest.GetResponse() MrMikeInNH@gmail.com Microsoft Dot NET Framework 2 30th Mar 2006 07:33 PM
Please help !! Problem about HttpWebRequest - GetResponse() japslam japslam via DotNetMonster.com Microsoft ASP .NET 5 22nd Apr 2005 06:49 PM
HttpWebRequest.GetResponse() Oemer Yildiz Microsoft Dot NET Framework 2 29th Jan 2005 09:30 AM
HttpWebRequest.GetResponse() problem Veerle Microsoft VB .NET 0 1st Mar 2004 03:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:36 PM.