6

나는 ASP.NET MVC 액션 메소드던지는 예외는 ASP.NET MVC에서 내부 예외를 표시

throw new Exception("outer", new SecurityException("inner")); 

실제로 죽음의 노란색 화면에 표시되는 오류에 다음 줄을 추가하는 경우 외부 예외에 대한 언급이 전혀없는 내부 SecurityException입니다.

SecurityException

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: inner

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: inner]

이 예상되는 동작입니까?

외부 예외가 어떤 유형인지는 중요하지 않습니다. 다른 SecurityException 인 경우에도 메시지는 절대로 표시되지 않습니다. 기본 SecurityException 오류 메시지는 너무 모호해서 더 이상 구체적인 정보를 추가하고 싶지 않습니다. 원래 SecurityException을 innerException으로 포함시키지 않더라도이 작업은 정상적으로 작동하지만 이상적으로는이 작업을 수행하려고합니다.

일반적으로
+0

이것은 securityexception뿐만 아니라 모든 내부 예외에 해당합니다. –

답변

-1

당신이해야 결코 던져 예외 클래스/객체를 직접하지만, 예를 들어, 사람을 도출 : 로그 또는 페이지에 무엇을 놓치고 있는지 이런 상황에서

throw new SecurityException("user should not be allowed to access this method..."); 

?

응용 프로그램 전역 예외 처리기를 사용하고 여기에서 Log4Net 또는 NLog과 함께 로그하는 경우 로깅 프레임 워크를 구성하고 사용하는 방법에 따라 외부에서 내부로 모든 예외 체인에 액세스 할 수 있어야합니다. IIS/ASP.NET의 Yellow 페이지는 완전하지는 않지만 스택 추적을 표시해야합니다.

throw new SecurityException("user should not be allowed...", exc); 

편집 : 당신은 당신이 이런 식으로 캐치에서 오는 실제 예외를 랩 catch 블록에서 자신의 예외를 throw 할 경우

당신이 무엇을 제안 시도하고 로그인 한 다음있어 Log4Net의 텍스트 파일 :

System.Security.SecurityException: more explicit exception ---> System.Security.SecurityException: original exception at EDICheckerApp.Program.boom() in C:\DEV_RPP\Program.cs:line 45
--- End of inner exception stack trace --- at EDICheckerApp.Program.boom() in C:\DEV_RPP\Program.cs:line 49
at EDICheckerApp.Program.Main(String[] args) in C:\DEV_RPP\Program.cs:line 27

+1

이것을 시도하면 내가 말하는 바를 이해할 수 있습니다 : { new SecurityException ("original exception"); } catch (SecurityException ex) { throw new SecurityException ("보다 명시적인 예외", 예); } –

+0

예, 이해하지만 로깅 프레임 워크로 모든 것을 덤프하려고합니다. 로그 파일에 무엇이 있습니까? –

+1

이 경우 메시지는 주로 개발자 용입니다.친숙한 오류 메시지를 발생시켜 개발자가 디버깅 시간에 볼 수있게하고 로깅을하지 않기를 원합니다. 따라서 이해하기 어려운 메시지를 이해하기 쉽습니다. –

5

이 동작은 ASP.NET "코어"에서 시작되었으며 ASP.NET MVC에서는 발생하지 않습니다. 안타깝게도 오류 포맷터 클래스는 내부적이며 소비 유형은 오류보고 메커니즘을 바꾸지 않고 동작을 조정할 수있는 확장 점을 제공하지 않습니다. 이 문제를 해결하려면 기본 "노란 죽음의 화면"페이지를 사용자가 선호하는 정보를 노출하는 사용자 정의 오류 페이지 /보기로 바꾸십시오.

이것은 제작 과정에서 일반적으로 수행해야하는 작업입니다. 귀하의 경우에는 ASP.NET 제공 기본값을 사용하는 대신 디버그 용 대체 버전을 사용한다는 의미입니다.

관련 문제