WebRequest Constructors

Definition

Initializes a new instance of the WebRequest class.

Overloads

WebRequest()

Initializes a new instance of the WebRequest class.

WebRequest(SerializationInfo, StreamingContext)

Initializes a new instance of the WebRequest class from the specified instances of the SerializationInfo and StreamingContext classes.

WebRequest()

Initializes a new instance of the WebRequest class.

protected:
 WebRequest();
protected WebRequest ();
Protected Sub New ()

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.

WebRequest(SerializationInfo, StreamingContext)

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);
new System.Net.WebRequest : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.WebRequest

Parameters

serializationInfo
SerializationInfo

A SerializationInfo that contains 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.

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.

Notice that an application must run in full trust mode when using serialization.

See also

Applies to