Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / November 2007

Tip: Looking for answers? Try searching our database.

HttpWebRequest.GetResponse()  Querystring length problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kamii47 - 02 Nov 2007 07:54 GMT
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
Fred Chateau - 09 Nov 2007 17:26 GMT
>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.

Signature

Regards,

Fred Chateau
fchateauAtComcastDotNet

Kamii47 - 10 Nov 2007 11:12 GMT
Can i have a example of that ?

> >I found a weird behavior of HttpWebRequest.GetResponse() in WM5
>
[quoted text clipped - 10 lines]
> I suggest you use a POST request or do a search on communicating with the
> server using Script tags from Javascript.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.