ViewStateException.Path 속성

정의

뷰 상태 예외를 발생시킨 HTTP 요청의 경로를 가져옵니다.

public:
 property System::String ^ Path { System::String ^ get(); };
public string Path { get; }
member this.Path : string
Public ReadOnly Property Path As String

속성 값

String

요청의 경로가 포함된 String입니다.

예제

다음 코드 예제에는 base64로 인코딩된 문자열을 역직렬화하 고 반환 하는 메서드를 구현 하는 방법을 보여 줍니다.는 ICollection 속성 설정의 컬렉션입니다. 합니다 Deserialize 메서드가 throw 할 수는 HttpException 포함 하는 예외를 ViewStateException 개체를 내부 예외로 합니다. 예제에서는 어떻게 catch 할 수 있습니다는 HttpException 예외에서 속성을 검색 하 고는 ViewStateException 개체입니다.

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

설명

이 속성에 동일한 값을 반환 합니다는 PATH_INFO 변수는 ServerVariables 속성입니다. 호스트 이름 뒤의 경로 부분을 반환 합니다. URL의 예를 들어 http://www.contoso.com/virdir/page.html, Path /virdir/page.html을 반환 합니다.

적용 대상