WebRequest.RegisterPrefix(String, IWebRequestCreate) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Remarks
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
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應