3
class XWebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri Url)
{
var Request = base.GetWebRequest(Url);
...........
return Request;
}
}
try
{
XWebClient Client = new XWebClient();
Client.DownloadString(new Uri("badurl:100500"));
}
catch
{
MessageBox.Show("exception");
}
我希望得到一个消息,但我得到一个未处理的异常。我究竟做错了什么?
例外: System.NotSupportedexception
消息: 的URI前缀无法识别
跟踪:
System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
System.Net.WebRequest.Create(Uri requestUri)
System.Net.WebClient.GetWebRequest(Uri address)
XWebClient.GetWebRequest(Uri Url) в [path]\XWebClient.cs:строка 28
System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
**是什么错误说**? – SLaks 2013-03-25 02:10:00
@Inisheer:他将不得不让代码在首位编译。 – 2013-03-25 02:18:42
@EdS。啊,真的。 – Inisheer 2013-03-25 02:19:16