ASP.NET-HttpWebRequest与HttpWebResponse的关系
1.HttpWebRequest: .NET.Framework的请求/响应模型的抽象基类,用于访问Internet数据。
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(Url);
提供的属性有:
|
标头 |
设置方法 |
| Accept | 由Accept属性设置 |
| Connection | 由Connection属性和KeepAlive属性设置 |
| Content-Length | 由ContentLength属性设置 |
| Content-Type | 由ContentType属性设置 |
| Expect | 由Expect属性设置 |
| Date | 由系统设置为当前日期 |
| Host | 由系统设置为当前主机信息 |
| If-Modified-Since | 由IfModifiedSince属性设置 |
| Range | 由Range属性设置 |
| Transfer-Encoding | 由TransferEncoding属性设置 |
| Referer | 由Referer属性设置 |
| User-Agent |
由UserAgent属性设置 |
2.HttpWebResponse: 对http协议进行了完整的封装( Header, Content, Cookie),与HttpWebRequest结合使用。
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
本文来自博客园,作者:꧁执笔小白꧂,转载请注明原文链接:https://www.cnblogs.com/qq2806933146xiaobai/p/15435684.html

浙公网安备 33010602011771号