HttpWebResponse.LastModified Propriedade
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém a última data e hora em que o conteúdo da resposta foi modificado.
public:
property DateTime LastModified { DateTime get(); };
public DateTime LastModified { get; }
member this.LastModified : DateTime
Public ReadOnly Property LastModified As DateTime
Uma DateTime que contém a data e hora em que o conteúdo da resposta foi modificado.
A instância atual foi descartada.
Este exemplo cria uma HttpWebRequest consulta e para uma resposta. Este exemplo verifica se a entidade solicitada foi modificada a qualquer momento hoje.
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()
A LastModified propriedade contém o valor do cabeçalho Last-Modified recebido com a resposta. Presume-se que a data e a hora sejam locais.
Produto | Versões |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Comentários do .NET
O .NET é um projeto código aberto. Selecione um link para fornecer comentários: