WebRequest.Create Method
.NET Framework 1.1
Initializes a new WebRequest.
Overload List
Initializes a new WebRequest instance for the specified URI scheme.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Function Create(String) As WebRequest
[C#] public static WebRequest Create(string);
[C++] public: static WebRequest* Create(String*);
[JScript] public static function Create(String) : WebRequest;
Initializes a new WebRequest instance for the specified URI scheme.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Function Create(Uri) As WebRequest
[C#] public static WebRequest Create(Uri);
[C++] public: static WebRequest* Create(Uri*);
[JScript] public static function Create(Uri) : WebRequest;
Example
[Visual Basic, C#, C++] The following example uses Create to instantiate an HttpWebRequest instance. A Uri representing the target url is used as the constructor parameter.
[Visual Basic, C#, C++] Note This example shows how to use one of the overloaded versions of Create. For other examples that might be available, see the individual overload topics.
[Visual Basic] ' Create a new 'Uri' object with the specified string. Dim myUri As New Uri("http://www.contoso.com") ' Create a new request to the above mentioned URL. Dim myWebRequest As WebRequest = WebRequest.Create(myUri) ' Assign the response object of 'WebRequest' to a 'WebResponse' variable. Dim myWebResponse As WebResponse = myWebRequest.GetResponse() [C#] // Create a new 'Uri' object with the specified string. Uri myUri =new Uri("http://www.contoso.com"); // Create a new request to the above mentioned URL. WebRequest myWebRequest= WebRequest.Create(myUri); // Assign the response object of 'WebRequest' to a 'WebResponse' variable. WebResponse myWebResponse= myWebRequest.GetResponse(); [C++] // Create a new 'Uri' object with the specified string. Uri* myUri = new Uri(S"http://www.contoso.com"); // Create a new request to the above mentioned URL. WebRequest* myWebRequest= WebRequest::Create(myUri); // Assign the response object of 'WebRequest' to a 'WebResponse' variable. WebResponse* myWebResponse = myWebRequest->GetResponse();
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
See Also
WebRequest Class | WebRequest Members | System.Net Namespace