HttpRequest标头响应C#

时间:2017-08-01 20:02:06

标签: c# httprequest

我有一个问题,使用HttpRequest()的响应我得到响应,但只是html而不是标题和我正在搜索的标题是在标题上所以这是我的代码

HttpRequest rq = new HttpRequest();
rq.Cookies = new CookieDictionary();
rq.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36";
rq.AllowAutoRedirect = true;
rq.IgnoreProtocolErrors = true;
rq.ConnectTimeout = TimeOut;
rq.KeepAlive = true;
var str = rq.Get("url").ToString();
if(str.Contains("404")){
}

我希望你能帮助我

1 个答案:

答案 0 :(得分:0)

我找到答案感谢您的帮助

var req = rq.Get("url");
if(req.StatusCode.ToString().Contains("NotFound") ){

}