Initializes a new System.Net.WebRequest instance for the specified URI scheme.
A System.Net.WebRequest descendant for the specific URI scheme.
Type Reason ArgumentNullException requestUriString is null. NotSupportedException The request scheme specified in requestUri is not registered. UriFormatException The URI specified in requestUriString is not a valid URI. System.Security.SecurityException The caller does not have permission to connect to the requested URI or a URI that the request is redirected to.
The WebRequest.Create(Uri) method returns a descendant of the System.Net.WebRequest class determined at run time as the closest registered match for requestUri.
For example, when a URI beginning with http:// or https:// is passed in requestUri, an System.Net.HttpWebRequest is returned by WebRequest.Create(Uri). If a URI beginning with ftp:// is passed instead, the WebRequest.Create(Uri) method will return a System.Net.FileWebRequest instance. If a URI beginning with file:// is passed instead, the WebRequest.Create(Uri) method will return a System.Net.FileWebRequest instance.
The pre-registered reserve types already registered include the following:
http://
https://
ftp://
file://
The .NET Framework includes support for the http://, https://, ftp://, and file:// URI schemes. Custom System.Net.WebRequest descendants to handle other requests are registered with the WebRequest.RegisterPrefix(string, IWebRequestCreate) method.
The WebRequest.Create(Uri) method uses the requestUriString parameter to create a Uri instance that it passes to the new System.Net.WebRequest.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Type | Reason |
---|---|
!:System.Security.Permissions.WebPermission | Requires permission to connect to the requested URI. See NetworkAccess.Connect. |