更新时间:2023-11-27 18:49:22
您可以使用.NET做一个HEAD请求,然后看一下响应的状态。
You can use .NET to do a HEAD request and then look at the status of the response.
您code会是这个样子(摘自The卑微的HTTP HEAD请求):
Your code would look something like this (adapted from The Lowly HTTP HEAD Request):
// create the request
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
// instruct the server to return headers only
request.Method = "HEAD";
// make the connection
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
// get the status code
HttpStatusCode status = response.StatusCode;
下面是一个清单,详细说明状态codeS 的可以通过状态code枚举返回。
Here's a list detailing the status codes that can be returned by the StatusCode enumerator.