Share via


Create Method (Uri)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Initializes a new WebRequest instance for the specified URI scheme.

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

Syntax

'Declaration
Public Shared Function Create ( _
    requestUri As Uri _
) As WebRequest
public static WebRequest Create(
    Uri requestUri
)
public:
static WebRequest^ Create(
    Uri^ requestUri
)
static member Create : 
        requestUri:Uri -> WebRequest 
public static function Create(
    requestUri : Uri
) : WebRequest

Parameters

Return Value

Type: System.Net. . :: . .WebRequest
A WebRequest descendant for the specified URI scheme.

Remarks

The Create method returns a descendant of the WebRequest class determined at run time as the closest registered match for requestUri.

For example, if you create a WebRequest descendant, Handler1, to handle requests to https://www.contoso.com/text/ and another named Handler2 to handle requests to https://www.contoso.com/code/, you can use Create method to return the WebRequest descendant associated with either specified URI.

To return a descendant of the WebRequest class based on only the scheme portion of a URI, use the CreateDefault method.

For example, when a URI beginning with http:// or https:// is passed in requestUri, an HttpWebRequest is returned by Create. If a URI beginning with ftp:// is passed instead, the Create method will return a FileWebRequest instance. If a URI beginning with file:// is passed instead, the Create method will return a FileWebRequest instance.

The pre-registered reserve types already registered include the following:

  • http://

  • https://

  • ftp://

  • file://

.NET Framework Security

See Also

Reference

WebRequest Class

Create Overload

System.Net Namespace