WebRequest.CreateDefault(Uri) WebRequest.CreateDefault(Uri) WebRequest.CreateDefault(Uri) WebRequest.CreateDefault(Uri) Method


为指定的 URI 方案初始化新的 WebRequest 实例。Initializes a new WebRequest instance for the specified URI scheme.

 static System::Net::WebRequest ^ CreateDefault(Uri ^ requestUri);
public static System.Net.WebRequest CreateDefault (Uri requestUri);
static member CreateDefault : Uri -> System.Net.WebRequest
Public Shared Function CreateDefault (requestUri As Uri) As WebRequest


Uri Uri Uri Uri

包含请求的资源的 URI 的 UriA Uri containing the URI of the requested resource.


指定的 URI 方案的 WebRequest 子代。A WebRequest descendant for the specified URI scheme.


requestUri 中指定的请求方案未注册。The request scheme specified in requestUri is not registered.

调用方没有连接到请求的 URI 或请求重定向到的 URI 的 WebPermissionAttribute 权限。The caller does not have WebPermissionAttribute permission to connect to the requested URI or a URI that the request is redirected to.


方法仅基于 URI WebRequest的方案部分返回子代实例。 CreateDefaultThe CreateDefault method returns a WebRequest descendant instance based on only the scheme portion of a URI.

例如http:// ,当requestUri传入的 URI 传入时CreateDefaultHttpWebRequest将返回。For example, when a URI beginning with http:// is passed in requestUri, an HttpWebRequest is returned by CreateDefault. 如果改为传递以file://开头的 URI,则CreateDefault该方法将返回FileWebRequestIf a URI beginning with file:// is passed instead, the CreateDefault method will return a FileWebRequest.


当你在应用程序中启用网络跟踪后,此成员将输出跟踪信息。This member outputs trace information when you enable network tracing in your application. 有关详细信息,请参阅.net 中的网络跟踪For more information, see Network Tracing in .NET.