Condividi tramite


WebRequest.CreateHttp Method (String)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Initializes a new HttpWebRequest instance for the specified URI string.

Namespace:  System.Net
Assembly:  System.Net (in System.Net.dll)

Syntax

'Declaration
Public Shared Function CreateHttp ( _
    requestUriString As String _
) As HttpWebRequest
public static HttpWebRequest CreateHttp(
    string requestUriString
)

Parameters

  • requestUriString
    Type: System.String
    A URI string that identifies the Internet resource.

Return Value

Type: System.Net.HttpWebRequest
An HttpWebRequest instance for the specific URI string.

Exceptions

Exception Condition
NotSupportedException

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

ArgumentNullException

requestUriString is nulla null reference (Nothing in Visual Basic).

SecurityException

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

UriFormatException

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 http:// is passed in the requestUriString parameter, a HttpWebRequest is returned by CreateHttp(String). Another other scheme will throw an 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.

The .NET Framework 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.

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

This member is present to support the .NET Compact Framework infrastructure in Silverlight for Windows Phone, and it is not intended to be used in your application code.

Version Information

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.