Export (0) Print
Expand All

WebRequest.CreateHttp Method (Uri)

Initializes a new HttpWebRequest instance for the specified URI.

Namespace:  System.Net
Assemblies:   System.Net.Requests (in System.Net.Requests.dll)
  System (in System.dll)

static member CreateHttp : 
        requestUri:Uri -> HttpWebRequest


Type: System.Uri

A URI that identifies the Internet resource.

Return Value

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


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


requestUri is a null reference (Nothing in Visual Basic).


The caller does not have 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.

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.

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(Uri) method can be used to create a descendant of the WebRequest class for other schemes.

.NET Framework

Supported in: 4.6, 4.5

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft