This documentation is archived and is not being maintained.

WebRequest.CreateDefault Method

Initializes a new WebRequest instance for the specified URI scheme.

[Visual Basic]
Public Shared Function CreateDefault( _
   ByVal requestUri As Uri _
) As WebRequest
public static WebRequest CreateDefault(
 Uri requestUri
public: static WebRequest* CreateDefault(
 Uri* requestUri
public static function CreateDefault(
   requestUri : Uri
) : WebRequest;


A Uri containing the URI of the requested resource.

Return Value

A WebRequest descendant for the specified URI scheme.


Exception Type Condition
NotSupportedException The request scheme specified in requestUri is not registered.
ArgumentNullException requestUri is a null reference (Nothing in Visual Basic).
SecurityException The caller does not have permission to connect to the requested URI or a URI that the request is redirected to.


The CreateDefault method returns a WebRequest descendant instance based on only the scheme portion of a URI.

For example, when a URI beginning with http:// is passed in requestUri, an HttpWebRequest is returned by CreateDefault. If a URI beginning with file:// is passed instead, the CreateDefault method will return a FileWebRequest.


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