2
我问了一个类似的问题,但对于curl和webclient。如何确保webclient处理错误,就像他们处理200
我发现卷曲的答案:
How to ensure that webclient/curl process 503 error like they process 200
CURLOPT_FAILONERROR
我想类似的东西,但对于Web客户端,而不是卷曲
我问了一个类似的问题,但对于curl和webclient。如何确保webclient处理错误,就像他们处理200
我发现卷曲的答案:
How to ensure that webclient/curl process 503 error like they process 200
CURLOPT_FAILONERROR
我想类似的东西,但对于Web客户端,而不是卷曲
的方式每一个问题是问,大概意思这个问题是与这个问题中链接的问题的重复。无论如何,我在这里提供的答案与我在此处的相同:
对于WebClient
您需要处理WebException.Response
。例如。此LINQPad查询转储由我的Web服务器的“未找到”错误网页提供的HTML:
Dim wc = New System.Net.WebClient
Try
Dim rd = wc.DownloadData(New Uri("http://localhost/test"))
rd.Dump
Catch Ex As System.Net.WebException
Dim rs = Ex.Response
Call (New StreamReader(rs.GetResponseStream)).ReadToEnd.Dump
End Try
当事情出错时,会执行rd.Dump吗?还是会异常直接? –
Wherre我可以看到这个dump thingy的文档吗?我没有看到它转储 –
为此,'转储'只是LINQPad的等同于'Console.WriteLine',但更多的格式。 –