ViewStateException.IsConnected Propiedad

Definición

Obtiene un valor que indica si el cliente está conectado al servidor actualmente.Gets a value indicating whether the client is currently connected to the server.

public:
 property bool IsConnected { bool get(); };
public bool IsConnected { get; }
member this.IsConnected : bool
Public ReadOnly Property IsConnected As Boolean

Valor de propiedad

Boolean

true si el cliente sigue conectado al servidor; en caso contrario, false.true if the client is still connected to the server; otherwise, false.

Ejemplos

En el ejemplo de código siguiente se muestra cómo implementar un método que deserializa una cadena codificada en Base64 y devuelve una ICollection colección de valores de propiedad.The following code example demonstrates how to implement a method that deserializes a base64-encoded string and returns an ICollection collection of property settings. El Deserialize método puede producir una HttpException excepción que contenga un ViewStateException objeto como excepción interna.The Deserialize method can throw an HttpException exception that contains a ViewStateException object as an inner exception. En el ejemplo se muestra cómo se puede detectar una HttpException excepción y recuperar las propiedades del 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   

Comentarios

Esta propiedad devuelve el mismo valor que cuando se llama a la IsClientConnected propiedad.This property returns the same value as calling the IsClientConnected property.

Se aplica a

Consulte también