Breyta

Deila með


HttpWebRequest.Date Property

Definition

Gets or sets the Date HTTP header value to use in an HTTP request.

public:
 property DateTime Date { DateTime get(); void set(DateTime value); };
public DateTime Date { get; set; }
member this.Date : DateTime with get, set
Public Property Date As DateTime

Property Value

The Date header value in the HTTP request.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

If the Date header is null, then the return value will be set to DateTime.MinValue.

The Date property is a standard System.DateTime object and can contain a System.DateTimeKind field of DateTimeKind.Local, DateTimeKind.Utc, or DateTimeKind.Unspecified. Any kind of time can be set when using the Date property. If DateTimeKind.Unspecified is set or retrieved, the Date property is assumed to be DateTimeKind.Local (local time).

The classes in the System.Net namespace always write it out the Date property on the wire during transmission in standard form using GMT (Utc) format.

If the Date property is set to DateTime.MinValue, then the Date HTTP header is removed from the Headers property and the WebHeaderCollection.

If the Date property is DateTime.MinValue, this indicates that the Date HTTP header is not included in the Headers property and the WebHeaderCollection.

Note

The value for this property is stored in WebHeaderCollection. If WebHeaderCollection is set, the property value is lost.

If the Date is set and an attempt is made to send a HttpWebRequest with no body, then a System.Net.ProtocolViolationException will be thrown by the BeginGetResponse, GetResponse, and EndGetResponse methods.

Applies to