using System.Web.Mvc;
namespace MvcApp.Filter
{
/// <summary>
/// 授权过滤器
/// </summary>
public class LoginAuthorizeAttribute : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
//判断是否跳过授权过滤器
if (filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true)
|| filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))
{
return;
}
//TODO:授权校验
}
}
这篇博客介绍了一个自定义的ASP.NET MVC授权过滤器`LoginAuthorizeAttribute`,该过滤器用于控制用户访问权限。它会检查Action或Controller是否标记了`AllowAnonymousAttribute`来决定是否跳过授权检查。博客内容主要涉及授权校验的实现细节。
1093





