WebRequest.RegisterPrefix(String, IWebRequestCreate) 方法
定義
註冊指定 URI 的 WebRequest 子代。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
參數
- prefix
- String
WebRequest 子代所服務的完整 URI 或 URI 前置詞。The complete URI or URI prefix that the WebRequest descendant services.
- creator
- IWebRequestCreate
WebRequest 呼叫以建立 WebRequest 子代的建立方法。The create method that the WebRequest calls to create the WebRequest descendant.
傳回
如果登錄成功,則為 true
,否則為 false
。true
if registration is successful; otherwise, false
.
例外狀況
備註
方法會將子系 RegisterPrefix 註冊 WebRequest 至服務要求。The RegisterPrefix method registers WebRequest descendants to service requests. WebRequest 子系通常會註冊來處理特定的通訊協定,例如 HTTP 或 FTP,但可以註冊來處理對伺服器上特定伺服器或路徑的要求。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://
如需詳細資訊,請參閱 Create(String) 和 Create(Uri) 方法。For more information, see the Create(String) and Create(Uri) methods.
不允許重複的首碼。Duplicate prefixes are not allowed. RegisterPrefixfalse
如果嘗試註冊重複的前置詞,則會傳回。RegisterPrefix returns false
if an attempt is made to register a duplicate prefix.
注意
HttpWebRequest根據預設,類別會註冊為 HTTP 和 HTTPS 配置的服務要求。The HttpWebRequest class is registered to service requests for HTTP and HTTPS schemes by default. 嘗試為這些配置註冊不同的子系 WebRequest 將會失敗。Attempts to register a different WebRequest descendant for these schemes will fail.