gpt4 book ai didi

c# - 扩展 HttpWebRequest

转载 作者:太空狗 更新时间:2023-10-30 01:06:33 25 4
gpt4 key购买 nike

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真的不能扩展吗?

最佳答案

你不能继承自HttpWebRequest 但你可以继承自WebRequest

检查类似问题的答案here .

关于c# - 扩展 HttpWebRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15174421/

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