0

The problem is that if I do Webclient.DownloadStringAsync(Uri), while Uri.length very long, I see the error: An exception occurred during a WebClient request

At URI for Webclient is a restriction on the length of the links? What about if the link is very long?

WebClient queueItem_client = new WebClient();
queueItem_client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(queueItem_client_DownloadStringCompleted);
            queueItem_client.DownloadStringAsync(execUri);

void queueItem_client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{}

In execUri link length 2234 characters.

enter image description here

if execUri is composed of about 500 characters, then comes the normal response. enter image description here

arsenium
  • 571
  • 1
  • 7
  • 20
  • Added a screenshot of the error. – arsenium Sep 04 '12 at 17:04
  • 1
    @arsenium: A screenshot of an error is useless. What is the error type, message, and stack trace of the exception and any inner exceptions? –  Sep 04 '12 at 17:25

1 Answers1

3

Some browsers implement a limit on the URI. See What is the maximum length of a URL in different browsers?. If at all possible for long Uri's (over 2000 characters) consider changing this request into a Post rather than GET and putting your parameters into the body.

Community
  • 1
  • 1
Jim Wooley
  • 10,169
  • 1
  • 25
  • 43
  • It's not just browsers which have a limit. Some network hardware (proxy servers, etc.) also have limits. Focusing solely on browser limits can be insufficient in some instances. As you say a correct use of the appropriate method to submit large amounts of data is probably more appropriate than focusing on URI length limits. – Matt Lacey Sep 05 '12 at 09:29