C# - Getting the response body from a 403 error

后端 未结 2 1567
北海茫月
北海茫月 2020-12-03 08:16

I\'m receiving a 403 error when requesting data from a URL. This is expected and I\'m not asking how to correct it.
When pasting this URL directly into my browser, I g

2条回答
  •  一向
    一向 (楼主)
    2020-12-03 08:47

    You're looking for the WebException.Response property:

    catch(WebException ex)
    {
         var response = (HttpWebResponse)ex.Response;
    }
    

提交回复
热议问题