HttpWebResponse::LastModified Property
.NET Framework (current version)
Gets the last date and time that the contents of the response were modified.
Assembly: System (in System.dll)
| Exception | Condition |
|---|---|
| ObjectDisposedException | The current instance has been disposed. |
The LastModified property contains the value of the Last-Modified header received with the response. The date and time are assumed to be local time.
This example creates an HttpWebRequest and queries for a response. This example then checks whether the entity requested had been modified any time today.
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();
.NET Framework
Available since 1.1
Available since 1.1
Show: