class AdvancedWebRequest : HttpWebRequest {
private static readonly ILog log = log4net.LogManager.GetLogger(typeof(AdvancedWebRequest));
public AdvancedWebRequest(string url, CookieContainer cookies = null) {
Create(url);
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22";
Referer = Address.AbsoluteUri;
if (cookies == null) {
CookieContainer = Program.request.CookieContainer;
} else {
CookieContainer = cookies;
}
}
}
这是我想做的事情,所以基本上得到已经设置了一些变量的 HttpWebRequest,所以我不能总是自己设置它们。
得到错误:
'System.Net.HttpWebRequest.HttpWebRequest()' is obsolete: 'This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.' \Extensions\AdvancedWebRequest.cs 14 10
有什么建议,不能HttpWebRequest
真正扩展吗?