问题在于,如果我执行Webclient.DownloadStringAsync(Uri)
,而Uri.length很长,我会看到错误:An exception occurred during a WebClient request
对于Webclient的URI是对链接长度的限制吗? 如果链接很长怎么办?
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)
{}
execUri
个链接长度为2234个字符。
如果execUri
由大约500个字符组成,那么就会出现正常响应。
答案 0 :(得分:3)
某些浏览器对URI实施限制。见What is the maximum length of a URL in different browsers?。如果可能长的Uri(超过2000个字符)考虑将此请求更改为Post而不是GET并将您的参数放入正文中。