![](/img/trans.png)
[英]How to get the response body and how to set the request body with HttpURLConnection class?
[英]How to get response body of Httpexception
我正在使用 Leaf.xnet 发送一个 webs 请求,它使用 httpwebrequests
当状态代码不是 200 时,我试图捕捉响应
catch (HttpException ex)
{
Console.WriteLine(ex.Body) #ex.Body is not a method but i want to read response of 404 400 status codes
}
设置 IgnoreProtocolErrors = true; 在 HttpRequest 对象中,所以当 HttpExceptions 发生时,它不会中断异常,而是作为正常响应处理。 你可以解析响应数据并做你的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.