Breyta

Deila með


WebRequest.RegisterPrefix(String, IWebRequestCreate) Method

Definition

Registers a WebRequest descendant for the specified URI.

public:
 static bool RegisterPrefix(System::String ^ prefix, System::Net::IWebRequestCreate ^ creator);
public static bool RegisterPrefix (string prefix, System.Net.IWebRequestCreate creator);
static member RegisterPrefix : string * System.Net.IWebRequestCreate -> bool
Public Shared Function RegisterPrefix (prefix As String, creator As IWebRequestCreate) As Boolean

Parameters

prefix
String

The complete URI or URI prefix that the WebRequest descendant services.

creator
IWebRequestCreate

The create method that the WebRequest calls to create the WebRequest descendant.

Returns

true if registration is successful; otherwise, false.

Exceptions

prefix is null

-or-

creator is null.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

The RegisterPrefix method registers WebRequest descendants to service requests. WebRequest descendants are typically registered to handle a specific protocol, such HTTP or FTP, but can be registered to handle a request to a specific server or path on a server.

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

  • http://

  • https://

  • ftp://

  • file://

For more information, see the Create(String) and Create(Uri) methods.

Duplicate prefixes are not allowed. RegisterPrefix returns false if an attempt is made to register a duplicate prefix.

Note

The HttpWebRequest class is registered to service requests for HTTP and HTTPS schemes by default. Attempts to register a different WebRequest descendant for these schemes will fail.

Applies to