gpt4 book ai didi

c# - HttpWebResponse 返回 404 错误

转载 作者:太空狗 更新时间:2023-10-29 23:53:54 27 4
gpt4 key购买 nike

如何让Httpwebresponse忽略404错误继续处理?这比在输入中查找异常更容易,因为这种情况很少发生。

最佳答案

我假设您的代码中某处有一行,例如:

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

只需将其替换为:

HttpWebResponse response;

try
{
response = request.GetResponse() as HttpWebResponse;
}
catch (WebException ex)
{
response = ex.Response as HttpWebResponse;
}

关于c# - HttpWebResponse 返回 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1857512/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com