HttpWebResponse.LastModified プロパティ

定義

応答の内容が最後に変更された日付と時刻を取得します。

public:
 property DateTime LastModified { DateTime get(); };
public DateTime LastModified { get; }
member this.LastModified : DateTime
Public ReadOnly Property LastModified As DateTime

プロパティ値

応答の内容が変更された日付と時刻を格納する DateTime

例外

現在のインスタンスは破棄されています。

この例では、 HttpWebRequest と を作成して応答を照会します。 次の例では、要求されたエンティティが今日いつでも変更されたかどうかを確認します。

Uri^ myUri = gcnew Uri( url );
// Creates an HttpWebRequest for the specified URL.
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) );
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() );
if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK )
{
   Console::WriteLine( "\r\nRequest succeeded and the requested information is in the response , Description : {0}",
      myHttpWebResponse->StatusDescription );
}
DateTime today = DateTime::Now;
// Uses the LastModified property to compare with today's date.
if ( DateTime::Compare( today, myHttpWebResponse->LastModified ) == 0 )
{
   Console::WriteLine( "\nThe requested URI entity was modified today" );
}      
else if ( DateTime::Compare( today, myHttpWebResponse->LastModified ) == 1 )
{
   Console::WriteLine( "\nThe requested URI was last modified on: {0}",
      myHttpWebResponse->LastModified );
}
// Releases the resources of the response.
myHttpWebResponse->Close();
Uri myUri = new Uri(url);
    // Creates an HttpWebRequest for the specified URL.
    HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri);
    HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
    if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
        Console.WriteLine("\r\nRequest succeeded and the requested information is in the response , Description : {0}",
                            myHttpWebResponse.StatusDescription);
    DateTime today = DateTime.Now;
    // Uses the LastModified property to compare with today's date.
    if (DateTime.Compare(today,myHttpWebResponse.LastModified) == 0)
        Console.WriteLine("\nThe requested URI entity was modified today");
    else
        if (DateTime.Compare(today,myHttpWebResponse.LastModified) == 1)
            Console.WriteLine("\nThe requested URI was last modified on:{0}",
                                myHttpWebResponse.LastModified);
    // Releases the resources of the response.
    myHttpWebResponse.Close();
Dim myUri As New Uri(url)
' Creates an HttpWebRequest for the specified URL.
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(myUri), HttpWebRequest)
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
If myHttpWebResponse.StatusCode = HttpStatusCode.OK Then
    Console.WriteLine(ControlChars.Lf + ControlChars.Cr + "Request succeeded and the requested information is in the response , Description : {0}", myHttpWebResponse.StatusDescription)
End If
Dim today As DateTime = DateTime.Now
' Uses the LastModified property to compare with today's date.
If DateTime.Compare(today, myHttpWebResponse.LastModified) = 0 Then
    Console.WriteLine(ControlChars.Cr + "The requested URI entity was modified today")
Else
    If DateTime.Compare(today, myHttpWebResponse.LastModified) =  1 Then
        Console.WriteLine(ControlChars.Cr + "The requested Uri was last modified on:{0}", myHttpWebResponse.LastModified)
    End If
End If
' Releases the resources of the response.
myHttpWebResponse.Close()

注釈

プロパティには LastModified 、応答で受信した Last-Modified ヘッダーの値が含まれます。 日付と時刻は現地時刻と見なされます。

適用対象