0
我正在开发MVC 4.0项目。为了完成基于操作方法授权的角色,我已经实现了自定义授权属性解决方案的解决方案。但是这种解决方案在审查中不被接受,并且我被告知要创建一个处理授权和路由的服务。执行基于角色授权的MVC路由服务
我正在开发MVC 4.0项目。为了完成基于操作方法授权的角色,我已经实现了自定义授权属性解决方案的解决方案。但是这种解决方案在审查中不被接受,并且我被告知要创建一个处理授权和路由的服务。执行基于角色授权的MVC路由服务
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");
}
}
}
}}