示例#1
0
 /// <summary>
 /// Handles the request when the user is not authorized
 /// </summary>
 protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
 {
     if (RefuseOnFail)
     {
         filterContext.Result = ResultHelper.ForbiddenResult(filterContext.Controller as dieuhoanhapkhau.web.Controllers.ControllerBase);
     }
     else
     {
         string          redirectOnSuccess = filterContext.HttpContext.Request.Url.PathAndQuery;
         VirtualPathData path = this.Routes.GetVirtualPath(filterContext.RequestContext, new RouteValueDictionary(new
         {
             controller = "Account",
             action     = "Login",
             returnUrl  = redirectOnSuccess,
             role       = this.UserRoles
         }));
         if (path == null)
         {
             throw new ArgumentException("Route for Account>Login not found.");
         }
         string loginUrl = path.VirtualPath;
         filterContext.Result = new RedirectResult(loginUrl, false);
     }
 }