HttpWebRequest和WebRequst

简介:

HttpWebRequest wr=(HttpWebRequest)WebRequest.Create("Url");

 

1、WebRequest是一个抽象类。其中包含了一个返回类型为WebRequest的静态方法  public static WebRequest Create(string requestUriString);

2、HttpWebRequest 类继承WebRequest。并且HttpWebRequest 类提供 System.Net.WebRequest 类的 HTTP 特定的实现。

 

3、HttpWebRequest类:提供WebRequest类的Http特定的实现。
    

HttpWebRequest 类对 WebRequest 中定义的属性和方法提供支持,也对使用户能够直接与使用 HTTP 的服务器交互的附加属性和方法提供支持。
不要使用构造函数创建HttpWebRequest实例,请使用System.Net.WebRequest.Create(URI uriString)来创建实例,如果URI是Http://或Https://,
返回的是HttpWebRequest对象。(建立请求特定URI的对象)

 

当向资源发送数据时,GetRequestStream方法返回用于发送数据的Stream对象。(获取请求数据的流对象)

 

GetResponse方法向RequestUri属性指定的资源发出同步请求并返回包含该响应的HttpWebResponse(获取来自internet的响应)



本文转自武沛齐博客园博客,原文链接:http://www.cnblogs.com/wupeiqi/archive/2012/11/12/2766585.html,如需转载请自行联系原作者

目录
相关文章
|
5月前
|
安全 C#
C#Webrequest类的使用
C#Webrequest类的使用
33 0
|
5月前
|
网络安全 C#
C# HttpWebRequest 获取 HTTPS 网页内容
C# HttpWebRequest 获取 HTTPS 网页内容
450 0
$request_uri和$uri
$request_uri This variable is equal to the *original* request URI as received from the client including the args. It cannot be modified. Look at $uri for the post-rewrite/altered URI. Does not in
1474 0
C# HttpWebRequest 笔记
C# HttpWebRequest 笔记
177 0
|
Web App开发 C# iOS开发
Csharp:WebClient and WebRequest use http download file
//Csharp:WebClient and WebRequest use http download file //20140318 塗聚文收錄 string filePath = "20140302.pdf"; string fileName = "http://www.dusystem.com/3.pdf"
1244 0
|
Web App开发
我的webrequest经验
1  webrequest 是什么:编程方式模拟web请求,利用webrequest可以实现 相当于一个浏览器请求一个网页的效果,但是它始终是模拟请求, 与浏览器输入框输入网址请求不一样。 2 程序设计中有时有这样的case,需要请求一个url,获得特定网页的部分html代码,比如特定的table,div片段。
782 0
|
数据安全/隐私保护