Редагувати

Поділитися через


WebRequest.CreateHttp Method

Definition

Initializes a new HttpWebRequest instance for the specified URI.

Overloads

CreateHttp(String)
Obsolete.

Initializes a new HttpWebRequest instance for the specified URI string.

CreateHttp(Uri)
Obsolete.

Initializes a new HttpWebRequest instance for the specified URI.

CreateHttp(String)

Source:
WebRequest.cs
Source:
WebRequest.cs
Source:
WebRequest.cs

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

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);
[System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.HttpWebRequest CreateHttp (string requestUriString);
static member CreateHttp : string -> System.Net.HttpWebRequest
[<System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member CreateHttp : string -> System.Net.HttpWebRequest
Public Shared Function CreateHttp (requestUriString As String) As HttpWebRequest

Parameters

requestUriString
String

A URI string that identifies the Internet resource.

Returns

An HttpWebRequest instance for the specific URI string.

Attributes

Exceptions

The request scheme specified in requestUriString is the http or https scheme.

requestUriString is null.

The caller does not have WebPermissionAttribute permission to connect to the requested URI or a URI that the request is redirected to.

The URI specified in requestUriString is not a valid URI.

Remarks

The CreateHttp(String) method returns an instance of the HttpWebRequest class for the requestUriString.

When a URI that begins with http:// or https:// is passed in the requestUriString parameter, a HttpWebRequest is returned by CreateHttp(String). Any other scheme will throw a NotSupportedException.

The CreateHttp(String) method uses the requestUriString parameter to create a Uri instance that it passes to the new HttpWebRequest. If the method is successful, the AllowReadStreamBuffering property on the returned HttpWebRequest instance is set to false.

.NET includes support for the http:// and https:// URI schemes. Custom WebRequest descendants to handle other requests are registered with the RegisterPrefix method. The Create(String) method can be used to create a descendant of the WebRequest class for other schemes.

Applies to

CreateHttp(Uri)

Source:
WebRequest.cs
Source:
WebRequest.cs
Source:
WebRequest.cs

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

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);
[System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.HttpWebRequest CreateHttp (Uri requestUri);
static member CreateHttp : Uri -> System.Net.HttpWebRequest
[<System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member CreateHttp : Uri -> System.Net.HttpWebRequest
Public Shared Function CreateHttp (requestUri As Uri) As HttpWebRequest

Parameters

requestUri
Uri

A URI that identifies the Internet resource.

Returns

An HttpWebRequest instance for the specific URI string.

Attributes

Exceptions

The request scheme specified in requestUri is the http or https scheme.

requestUri is null.

The caller does not have WebPermissionAttribute permission to connect to the requested URI or a URI that the request is redirected to.

The URI specified in requestUri is not a valid URI.

Remarks

The CreateHttp(Uri) method returns an instance of the HttpWebRequest class for the requestUri.

When a URI that begins with http:// or http:// is passed in the requestUri parameter, an HttpWebRequest is returned by CreateHttp(Uri). Another other scheme will throw a NotSupportedException.

The CreateHttp(Uri) method uses the requestUri parameter to create a new HttpWebRequest instance. If the method is successful, the AllowReadStreamBuffering property on the returned HttpWebRequest instance is set to false.

.NET includes support for the http:// and https:// URI schemes. Custom WebRequest descendants to handle other requests are registered with the RegisterPrefix method. The Create(Uri) method can be used to create a descendant of the WebRequest class for other schemes.

Applies to