Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

WebRequest.CreateHttp Method (Uri)

Initializes a new HttpWebRequest instance for the specified URI.

Namespace:  System.Net
Assembly:  System.Net (in System.Net.dll)
public static HttpWebRequest CreateHttp(
	Uri requestUri
)

Parameters

requestUri
Type: System.Uri
A URI that identifies the Internet resource.

Return Value

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

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

ArgumentNullException

requestUri is null.

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 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.

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.

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

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.