gpt4 book ai didi

c# - 在检查 http 状态代码时收到错误消息 - 远程服务器返回错误 : (503) Server Unavailable

转载 作者:可可西里 更新时间:2023-11-01 17:35:10 27 4
gpt4 key购买 nike

如果它是一个有效的 url,我想插入 url/链接。为此我正在检查状态代码。但是对于某些链接,即使它是有效链接,我也会收到此错误

    HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(LinkCheck);
myHttpWebRequest.Timeout = 150000;
myHttpWebRequest.Method = "HEAD";
myHttpWebRequest.UserAgent = "Foo";
myHttpWebRequest.Accept = "*/*";
myHttpWebRequest.AllowAutoRedirect = false;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();//getting error here
MyStatusCode = ((int)myHttpWebResponse.StatusCode);
myHttpWebResponse.Close();

输入- http://www.jabong.com/men/输出应该来= 200但它的抛出错误

最佳答案

server您发出的请求似乎不支持 HEAD HTTP 动词。将您的请求更改为 GET,它将正常工作:

myHttpWebRequest.Method = "GET";

关于c# - 在检查 http 状态代码时收到错误消息 - 远程服务器返回错误 : (503) Server Unavailable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33328471/

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