2012-09-17 119 views
0

我正在開發MVC 4.0項目。爲了完成基於操作方法授權的角色,我已經實現了自定義授權屬性解決方案的解決方案。但是這種解決方案在審查中不被接受,並且我被告知要創建一個處理授權和路由的服務。執行基於角色授權的MVC路由服務

回答

0
On the gloabl.asas.cs file you can add the below event and then do whatever you want to do 

    protected void Application_AuthenticateRequest(Object sender, EventArgs e) 
       { 
        if (Features.UserValidationEnabled) 
        { 
      if (!safeExtension && Security.CurrentUser.IsInRole("User")) 
          { 
           if (!AccountManager.CheckFlag(Security.CurrentUser, AccountManager.Capabilities.IsValidated)) 
           { 
            if (!HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath.StartsWith("~/Account", StringComparison.OrdinalIgnoreCase)) 
            { 
             Response.Redirect("~/Account/Validate"); 
            } 
           } 
     } 
     }}