ViewStateException.Referer Propriedade
Definição
Obtém a URL da página que é vinculada à página em que ocorreu a exceção de estado de exibição.Gets the URL of the page that linked to the page where the view-state exception occurred.
public:
property System::String ^ Referer { System::String ^ get(); };
public string Referer { get; }
member this.Referer : string
Public ReadOnly Property Referer As String
Valor da propriedade
Um String que contém o referenciador http.A String containing the HTTP referrer.
Exemplos
O exemplo de código a seguir demonstra como implementar um método que desserializa uma cadeia de caracteres codificada em Base64 e retorna uma ICollection coleção de configurações de propriedade.The following code example demonstrates how to implement a method that deserializes a base64-encoded string and returns an ICollection collection of property settings. O Deserialize método pode gerar uma HttpException exceção que contém um ViewStateException objeto como uma exceção interna.The Deserialize method can throw an HttpException exception that contains a ViewStateException object as an inner exception. O exemplo mostra como você pode capturar uma HttpException exceção e recuperar as propriedades do ViewStateException objeto.The example shows how you can catch an HttpException exception and retrieve the properties from the ViewStateException object.
private ICollection LoadControlProperties(string serializedProperties)
{
ICollection controlProperties = null;
// Create an ObjectStateFormatter to deserialize the properties.
ObjectStateFormatter formatter = new ObjectStateFormatter();
try
{
// Call the Deserialize method.
controlProperties = (ArrayList)formatter.Deserialize(serializedProperties);
}
catch (HttpException e)
{
ViewStateException vse = (ViewStateException)e.InnerException;
String logMessage;
logMessage = "ViewStateException. Path: " + vse.Path + Environment.NewLine;
logMessage += "PersistedState: " + vse.PersistedState + Environment.NewLine;
logMessage += "Referer: " + vse.Referer + Environment.NewLine;
logMessage += "UserAgent: " + vse.UserAgent + Environment.NewLine;
LogEvent(logMessage);
if (vse.IsConnected)
{
HttpContext.Current.Response.Redirect("ErrorPage.aspx");
}
else
{
throw e;
}
}
return controlProperties;
}
Private Function LoadControlProperties(ByVal serializedProperties As String) As ICollection
Dim controlProperties As ICollection = Nothing
' Create an ObjectStateFormatter to deserialize the properties.
Dim formatter As New ObjectStateFormatter()
Try
' Call the Deserialize method.
controlProperties = CType(formatter.Deserialize(serializedProperties), ArrayList)
Catch e As HttpException
Dim vse As ViewStateException
Dim logMessage As String
vse = e.InnerException
logMessage = "ViewStateException. Path: " + vse.Path + Environment.NewLine
logMessage += "PersistedState: " + vse.PersistedState + Environment.NewLine
logMessage += "Referer: " + vse.Referer + Environment.NewLine
logMessage += "UserAgent: " + vse.UserAgent + Environment.NewLine
LogEvent(logMessage)
If (vse.IsConnected) Then
HttpContext.Current.Response.Redirect("ErrorPage.aspx")
Else
Throw e
End If
End Try
Return controlProperties
End Function 'LoadControlProperties
Comentários
Essa propriedade retorna o mesmo valor que a HTTP_REFERER variável na ServerVariables propriedade.This property returns the same value as the HTTP_REFERER variable in the ServerVariables property. O valor é uma cadeia de caracteres vazia ("") se não houver nenhuma solicitação anterior vinculada à página.The value is an empty string ("") if no previous request linked to the page.