This documentation is archived and is not being maintained.

WebRequest.RegisterPrefix Method

Registers a WebRequest descendant for the specified URI.

[Visual Basic]
Public Shared Function RegisterPrefix( _
   ByVal prefix As String, _
   ByVal creator As IWebRequestCreate _
) As Boolean
public static bool RegisterPrefix(
 string prefix,
 IWebRequestCreate creator
public: static bool RegisterPrefix(
 String* prefix,
 IWebRequestCreate* creator
public static function RegisterPrefix(
   prefix : String,
 creator : IWebRequestCreate
) : Boolean;


The complete URI or URI prefix that the WebRequest descendant services.
The create method that the WebRequest calls to create the WebRequest descendant.

Return Value

true if registration is successful; otherwise, false.


Exception Type Condition
ArgumentNullException prefix is a null reference (Nothing in Visual Basic)


creator is a null reference (Nothing).


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.

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.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

WebRequest Class | WebRequest Members | System.Net Namespace