2010-12-08 2 views
2

사용자가 권한이없는 영역에 사용자가 액세스하려고 시도 할 때마다 보안 예외를 발생시키고 싶습니다. AuthorizeAttribute가 제공하는 것보다 더 많은 컨트롤이 필요합니다. 액션 : 내가 가지고있는 것 : throw new HttpException((int)HttpStatusCode.Unauthorized, String.Empty); 이것은 404와 403을 위해 잘 작동합니다.MVC2에서의 Throwing 401

Description: An unhandled exception occurred during the 

execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 

401을 던질 수있는 방법이 있나요 또는 사용자 정의 (401)보기로 사용자를 리디렉션 단지 예이다 : 그러나 내가 대신 얻는 것은 500 오류입니다.

답변

0

도움 주셔서 감사합니다. Ardman. 나는 HttpUnauthorized ActionResult를 사용해 보았지만 ActionResult가 실제로 원하지 않는 로그인 페이지로 리다이렉트하기 때문에 사용자를 401 에러 페이지로 리다이렉션하기로 결정했다.