2010-01-08 1 views
1

을함으로써 Application_Error + 세션에 Global.asax에 1.0 파일 3.5 문제를 변환 리디렉션하려고하는 것은 이것이다 :은 Global.asax에에 따라서

보호 무효함으로써 Application_Error (개체를 보낸 사람, 경우 System.EventArgs { 세션 [ "인 CustomError "=이 Server.GetLastError(); Server.ClearError를(); Response.Redirect를 ("~/ErrorPage.aspx ");}

그리고 ErrorPage.aspx에

이있다 :

개인 무효 Page_Load (개체 발신자, System.E ventArgs e) { 예외 currentException = ((Exception) Session [ "CustomError"]). InnerException;

//if (currentException! = null) txtErrorMessage.Text = currentException.Message;

// 내부 예외를 통해 반복합니다. currentException = (예외) 세션 [ "CustomError"]; (currentException! = null) { message.Append (currentException.Message) .Append ("\ r \ n"). Append (currentException.StackTrace); message.Append ("\ n ================================ ==== \ n "); currentException = currentException.InnerException; }

이전 1.0 코드이므로 3.5 Global.asax 파일로 변환하면 barfs가됩니다. "세션"을 사용할 수 없으며 리디렉션 할 수 없다고 알려줍니다. 문제 중 하나는 Application_Start에서 발생하는 오류도있을 수 있다고 생각합니다. 그러나 모든 응용 프로그램 시작 코드를 주석으로 처리하더라도 오류가 발생하지만 오류 페이지로 리디렉션되지 않습니다.

답변

0

이 링크는 도움이 될 수 있습니다 : Exceptional Gotchas!. 또한 web.config 파일을 사용하여 오류에 대한 기본 리디렉션 페이지를 정의하십시오.