WebRequest.CreateHttp WebRequest.CreateHttp WebRequest.CreateHttp WebRequest.CreateHttp Method

定义

为指定的 URI 初始化新的 HttpWebRequest 实例。Initializes a new HttpWebRequest instance for the specified URI.

重载

CreateHttp(String) CreateHttp(String) CreateHttp(String) CreateHttp(String)

为指定的 URI 字符串初始化新的 HttpWebRequest 实例。Initializes a new HttpWebRequest instance for the specified URI string.

CreateHttp(Uri) CreateHttp(Uri) CreateHttp(Uri) CreateHttp(Uri)

为指定的 URI 初始化新的 HttpWebRequest 实例。Initializes a new HttpWebRequest instance for the specified URI.

CreateHttp(String) CreateHttp(String) CreateHttp(String) CreateHttp(String)

为指定的 URI 字符串初始化新的 HttpWebRequest 实例。Initializes a new HttpWebRequest instance for the specified URI string.

public:
 static System::Net::HttpWebRequest ^ CreateHttp(System::String ^ requestUriString);
public static System.Net.HttpWebRequest CreateHttp (string requestUriString);
static member CreateHttp : string -> System.Net.HttpWebRequest
Public Shared Function CreateHttp (requestUriString As String) As HttpWebRequest

参数

requestUriString
String String String String

标识 Internet 资源的 URI 字符串。A URI string that identifies the Internet resource.

返回

特定 URI 字符串的 HttpWebRequest 实例。An HttpWebRequest instance for the specific URI string.

异常

requestUriString 中指定的请求方案为 http 或 https 方案。The request scheme specified in requestUriString is the http or https scheme.

requestUriStringnullrequestUriString is null.

调用方没有连接到请求的 URI 或请求重定向到的 URI 的 WebPermissionAttribute 权限。The caller does not have WebPermissionAttribute permission to connect to the requested URI or a URI that the request is redirected to.

requestUriString 中指定的 URI 不是有效的 URI。The URI specified in requestUriString is not a valid URI.

注解

方法返回的HttpWebRequestrequestUriString的实例。 CreateHttp(String)The CreateHttp(String) method returns an instance of the HttpWebRequest class for the requestUriString.

http:// https://如果在参数requestUriString中传递以或开头的 URI, CreateHttp(String)则将返回。HttpWebRequestWhen a URI that begins with http:// or https:// is passed in the requestUriString parameter, a HttpWebRequest is returned by CreateHttp(String). 任何其他方案都将引发NotSupportedExceptionAny other scheme will throw a NotSupportedException.

方法使用参数创建它传递给新HttpWebRequest的实例。Uri requestUriString CreateHttp(String)The CreateHttp(String) method uses the requestUriString parameter to create a Uri instance that it passes to the new HttpWebRequest. 如果该方法成功, AllowReadStreamBuffering则返回HttpWebRequest的实例的属性将设置为falseIf the method is successful, the AllowReadStreamBuffering property on the returned HttpWebRequest instance is set to false.

.Net 包括对http://https:// URI 方案的支持。.NET includes support for the http:// and https:// URI schemes. 用方法注册自定义WebRequest子代来处理其他请求。 RegisterPrefixCustom WebRequest descendants to handle other requests are registered with the RegisterPrefix method. 方法可用于为其他方案创建WebRequest类的后代。 Create(String)The Create(String) method can be used to create a descendant of the WebRequest class for other schemes.

CreateHttp(Uri) CreateHttp(Uri) CreateHttp(Uri) CreateHttp(Uri)

为指定的 URI 初始化新的 HttpWebRequest 实例。Initializes a new HttpWebRequest instance for the specified URI.

public:
 static System::Net::HttpWebRequest ^ CreateHttp(Uri ^ requestUri);
public static System.Net.HttpWebRequest CreateHttp (Uri requestUri);
static member CreateHttp : Uri -> System.Net.HttpWebRequest
Public Shared Function CreateHttp (requestUri As Uri) As HttpWebRequest

参数

requestUri
Uri Uri Uri Uri

标识 Internet 资源的 URI。A URI that identifies the Internet resource.

返回

特定 URI 字符串的 HttpWebRequest 实例。An HttpWebRequest instance for the specific URI string.

异常

requestUri 中指定的请求方案为 http 或 https 方案。The request scheme specified in requestUri is the http or https scheme.

调用方没有连接到请求的 URI 或请求重定向到的 URI 的 WebPermissionAttribute 权限。The caller does not have WebPermissionAttribute permission to connect to the requested URI or a URI that the request is redirected to.

requestUri 中指定的 URI 不是有效的 URI。The URI specified in requestUri is not a valid URI.

注解

方法返回的HttpWebRequestrequestUri的实例。 CreateHttp(Uri)The CreateHttp(Uri) method returns an instance of the HttpWebRequest class for the requestUri.

http:// http://如果在参数requestUri中传递以或开头的 URI, CreateHttp(Uri)则将返回。HttpWebRequestWhen a URI that begins with http:// or http:// is passed in the requestUri parameter, an HttpWebRequest is returned by CreateHttp(Uri). 其他方案将引发NotSupportedExceptionAnother other scheme will throw a NotSupportedException.

方法使用参数创建新HttpWebRequest的实例。 requestUri CreateHttp(Uri)The CreateHttp(Uri) method uses the requestUri parameter to create a new HttpWebRequest instance. 如果该方法成功, AllowReadStreamBuffering则返回HttpWebRequest的实例的属性将设置为falseIf the method is successful, the AllowReadStreamBuffering property on the returned HttpWebRequest instance is set to false.

.Net 包括对http://https:// URI 方案的支持。.NET includes support for the http:// and https:// URI schemes. 用方法注册自定义WebRequest子代来处理其他请求。 RegisterPrefixCustom WebRequest descendants to handle other requests are registered with the RegisterPrefix method. 方法可用于为其他方案创建WebRequest类的后代。 Create(Uri)The Create(Uri) method can be used to create a descendant of the WebRequest class for other schemes.

适用于