WebRequest.Create Method (System.Net)

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages

Search Just What's on Your Mind ? . . .

*this search pane is awesome, also enhanced by google, you won't h'v to leave MCB for your regular google search, thanks to magical power of ajax & jquery.


Hi Viewer,

*Please scroll down for your Story, Meanwhile as a MCB user please be noted: We do not allow typical good-bad-foul comment culture in this platform, rather if you want, you may post a counter-constructive story to this story by copy/paste this post link in your next Publish screen. Moreover MCB is an open platform where anybody can moderate anybody's post.

You may add your Story ;

Visit & Add: SocialStory

Add your News,
Views,
Consciences,
Etc.
as mcbStory

How to Post on MCB ?
No SignUp,
Just LogIn with our open credentials:

Publish News, Views, Consciences, Etc. 

Pick any one to Publish:

#1 mcb

#2 MyCtgBangla

#3 mcbStory

#4 MyStory

#5 PEOPLEPRESS

#6 WerMCBzen

WerMCBzen

Power to Edit/Add/Improve any Post ! 

Visit  MCB Policy

:) Citizen Journalism :)

mcb post icon


MCB is an Open Online Platform with a unique, one & only Open Online Profile – ‘WerMCBzen(wermcbzen)’ where you Possess the Power to Edit/Add/Improve any post or anybody’s content, but you should keep in mind, that Power always comes with some sort of responsibilities. So please be responsible by yourself to your Power.  It is made with Love for Lovable & Sensible People Only.

Story starts  hereThis image has an empty alt attribute; its file name is mcb-mversion-logo.png

mcb post icon

Your Story here :

0
(0)
11 views

WebRequest.Create Method (System.Net)

Overloads

Create(String)

Initializes a new WebRequest instance for the specified URI scheme.

Create(Uri)

Initializes a new WebRequest instance for the specified URI scheme.

Create(String)

Initializes a new WebRequest instance for the specified URI scheme.

public: static System::Net::WebRequest ^ Create(System::String ^ requestUriString);public static System.Net.WebRequest Create (string requestUriString);static member Create : string -> System.Net.WebRequestPublic Shared Function Create (requestUriString As String) As WebRequest

Parameters

Returns

WebRequest

A WebRequest descendant for the specific URI scheme.

Exceptions

Examples

The following example uses Create to instantiate an HttpWebRequest instance. A string representing the target URL is used as the constructor parameter.

Uri^ ourUri = gcnew Uri( url ); // Create a ‘WebRequest’ object with the specified url. WebRequest^ myWebRequest = WebRequest::Create( url ); // Send the ‘WebRequest’ and wait for response. WebResponse^ myWebResponse = myWebRequest->GetResponse(); // Use “ResponseUri” property to get the actual Uri from where the response was attained. if ( ourUri->Equals( myWebResponse->ResponseUri ) ) { Console::WriteLine( “nRequest Url : {0} was not redirected”, url ); } else { Console::WriteLine( “nRequest Url : {0} was redirected to {1}”, url, myWebResponse->ResponseUri ); } // Release resources of response object. myWebResponse->Close(); Uri ourUri = new Uri(url); // Create a ‘WebRequest’ object with the specified url. WebRequest myWebRequest = WebRequest.Create(url); // Send the ‘WebRequest’ and wait for response. WebResponse myWebResponse = myWebRequest.GetResponse(); // Use “ResponseUri” property to get the actual Uri from where the response was attained. if (ourUri.Equals(myWebResponse.ResponseUri)) Console.WriteLine(“nRequest Url : {0} was not redirected”,url); else Console.WriteLine(“nRequest Url : {0} was redirected to {1}”,url,myWebResponse.ResponseUri); // Release resources of response object. myWebResponse.Close(); Dim ourUri As New Uri(url) ‘ Create a ‘WebRequest’ object with the specified url. Dim myWebRequest As WebRequest = WebRequest.Create(url) ‘ Send the ‘WebRequest’ and wait for response. Dim myWebResponse As WebResponse = myWebRequest.GetResponse() ‘ “ResponseUri” property is used to get the actual Uri from where the response was attained. If ourUri.Equals(myWebResponse.ResponseUri) Then Console.WriteLine(ControlChars.Cr + “Request Url : {0} was not redirected”, url) Else Console.WriteLine(ControlChars.Cr + “Request Url : {0} was redirected to {1}”, url, myWebResponse.ResponseUri) End If ‘ Release resources of response object. myWebResponse.Close()

Remarks

The Create method returns a descendant of the 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 HttpWebRequest is returned by Create. If a URI beginning with ftp:// is passed instead, the Create method will return a FtpWebRequest instance. If a URI beginning with file:// is passed instead, the Create method will return a FileWebRequest instance.

The pre-registered reserve types already registered include the following:

  • http://

  • https://

  • ftp://

  • file://

.NET includes support for the http://, https://, ftp://, and file:// URI schemes. Custom WebRequest descendants to handle other requests are registered with the RegisterPrefix method.

The Create method uses the requestUriString parameter to create a Uri instance that it passes to the new WebRequest.

Note

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

See also

Applies to

Create(Uri)

Initializes a new WebRequest instance for the specified URI scheme.

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

Parameters

Returns

WebRequest

A WebRequest descendant for the specified URI scheme.

Exceptions

Examples

The following example uses Create to instantiate an HttpWebRequest instance. A Uri representing the target URL is used as the constructor parameter.

// Create a new ‘Uri’ object with the specified string. Uri^ myUri = gcnew 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(); // 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(); ‘ 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()

Remarks

The Create method returns a descendant of the WebRequest class determined at run time as the closest registered match for requestUri.

For example, if you create a WebRequest descendant, Handler1, to handle requests to http://www.contoso.com/text/ and another named Handler2 to handle requests to http://www.contoso.com/code/, you can use Create method to return the WebRequest descendant associated with either specified URI.

To return a descendant of the WebRequest class based on only the scheme portion of a URI, use the CreateDefault method.

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

The pre-registered reserve types already registered include the following:

  • http://

  • https://

  • ftp://

  • file://

.NET includes support for the http://, https://, ftp://, and file:// URI schemes. Custom WebRequest descendants to handle other requests are registered with the RegisterPrefix method.

Note

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

Applies to


MCB Love to Mention : )

Content Courtesy →

WebRequest.Create Method (System.Net)

Have A Views ?

Pay A Visit :

MCB-ParallelInternetWorld

How useful was this post?

Click on a star to rate it!

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages

Search Just What's on Your Mind ? . . .

*this search pane is awesome, also enhanced by google, you won't h'v to leave MCB for your regular google search, thanks to magical power of ajax & jquery.

*please keep in mind your post/page is always editable by the open online profile: WerMCBzen.

MCB is an Open Online Platform with a unique, one & only Open Online Profile – ‘WerMCBzen(wermcbzen)’ where you Possess the Power to Edit/Add/Improve any post or anybody’s content, but you should keep in mind, that Power always comes with some sort of responsibilities. So please be responsible by yourself to your Power.  It is made with Love for Lovable & Sensible People Only.

Edit: You're Empowered for Excellence !