WebRequest Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the WebRequest class.
Overloads
WebRequest() |
Obsolete.
Initializes a new instance of the WebRequest class. |
WebRequest(SerializationInfo, StreamingContext) |
Obsolete.
Initializes a new instance of the WebRequest class from the specified instances of the SerializationInfo and StreamingContext classes. |
WebRequest()
- Source:
- WebRequest.cs
- Source:
- WebRequest.cs
- Source:
- WebRequest.cs
Caution
WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
Initializes a new instance of the WebRequest class.
protected:
WebRequest();
protected WebRequest ();
[System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected WebRequest ();
Protected Sub New ()
- Attributes
Examples
The following example shows how to create a WebRequest instance by calling the Create method on the WebRequest class.
WebRequest^ myRequest = WebRequest::Create( "http://www.contoso.com" );
WebRequest myRequest = WebRequest.Create("http://www.contoso.com");
Dim myRequest As WebRequest = WebRequest.Create("http://www.contoso.com")
Remarks
Use the Create method to initialize new WebRequest instances. Do not use the constructor.
Applies to
WebRequest(SerializationInfo, StreamingContext)
- Source:
- WebRequest.cs
- Source:
- WebRequest.cs
- Source:
- WebRequest.cs
Caution
WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
Initializes a new instance of the WebRequest class from the specified instances of the SerializationInfo and StreamingContext classes.
protected:
WebRequest(System::Runtime::Serialization::SerializationInfo ^ serializationInfo, System::Runtime::Serialization::StreamingContext streamingContext);
protected WebRequest (System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext);
[System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected WebRequest (System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext);
new System.Net.WebRequest : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.WebRequest
[<System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Net.WebRequest : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.WebRequest
Protected Sub New (serializationInfo As SerializationInfo, streamingContext As StreamingContext)
Parameters
- serializationInfo
- SerializationInfo
The information required to serialize the new WebRequest instance.
- streamingContext
- StreamingContext
A StreamingContext that indicates the source of the serialized stream associated with the new WebRequest instance.
- Attributes
Exceptions
Any attempt is made to access the constructor, when the constructor is not overridden in a descendant class.
Remarks
When implemented by a descendant class, this constructor implements the ISerializable interface for the WebRequest descendant.
Note
An application must run in full trust mode when using serialization.