WebRequest 构造函数

定义

初始化 WebRequest 类的新实例。Initializes a new instance of the WebRequest class.

重载

WebRequest()

初始化 WebRequest 类的新实例。Initializes a new instance of the WebRequest class.

WebRequest(SerializationInfo, StreamingContext)

WebRequestSerializationInfo 类的指定实例初始化 StreamingContext 类的新实例。Initializes a new instance of the WebRequest class from the specified instances of the SerializationInfo and StreamingContext classes.

WebRequest()

初始化 WebRequest 类的新实例。Initializes a new instance of the WebRequest class.

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

示例

下面的示例演示如何 WebRequest 通过 Create 在类上调用方法来创建实例 WebRequestThe 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")

注解

使用 Create 方法初始化新 WebRequest 实例。Use the Create method to initialize new WebRequest instances. 不要使用构造函数。Do not use the constructor.

适用于

WebRequest(SerializationInfo, StreamingContext)

WebRequestSerializationInfo 类的指定实例初始化 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
Protected Sub New (serializationInfo As SerializationInfo, streamingContext As StreamingContext)

参数

serializationInfo
SerializationInfo

SerializationInfo,包含序列化新的 WebRequest 实例所需的信息。A SerializationInfo that contains the information required to serialize the new WebRequest instance.

streamingContext
StreamingContext

StreamingContext,指示与新的 WebRequest 实例关联的序列化流的源。A StreamingContext that indicates the source of the serialized stream associated with the new WebRequest instance.

例外

当未在子类中重写该构造函数时,尝试访问该构造函数。Any attempt is made to access the constructor, when the constructor is not overridden in a descendant class.

注解

当由子类实现时,此构造函数实现 ISerializable 子代的接口 WebRequestWhen 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.

适用于