내가 역할로 설정하고있는 홈 컨트롤러에서 MVC 3에서 권한 부여를 정의하려고 ...사용자 정의 권한을 부여 mvc3 오류
Session["role"] = "Admin";
내가
SiteRoles role = (SiteRoles)httpContext.Session["role"];
에서 오류가 발생하고
지정 된 캐스트가 유효하지 않습니다.
실마리가 없습니다.
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
if (httpContext == null)
throw new ArgumentNullException("httpContext");
string[] users = Users.Split(',');
if (!httpContext.User.Identity.IsAuthenticated)
return false;
string role = (string)httpContext.Session["role"];
if (Roles != 0 && ((Roles & role) != role))
return false;
return true;
}
나는 또한 다음 예제에서 ... http : //mvchosting.asphostcentral.com/post/ASPNET-MVC-Hosting-Working-with-Custom-Authorisation-in-ASPNET-MVC-Framework.aspx – Beginner