【发布时间】:2014-07-13 12:11:02
【问题描述】:
我正在使用 MVC 4。
我对这个继承自 System.Web.Mvc.ActionFilterAttribute 的客户属性进行编码
public class AuthorizedAttribute : ActionFilterAttribute
{
public AccessLevel Threshold { get; set; }
public AuthorizedAttribute()
{
Threshold = AccessLevel.Anonymous;
}
public AuthorizedAttribute(AccessLevel threshold)
{
Threshold = threshold;
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//some actions
base.OnActionExecuting(filterContext);
}
}
我在我的UserControllerManage 中使用它
public class UserController : Controller
{
[HttpGet]
[Authorized(AccessLevel.Administrator)]
public ViewResult Manage()
{
return View();
}
}
我在我的属性构造函数中,在覆盖的方法OnActionExecuting 和我的UserController 中放置了一个断点,当我在调试模式下通过浏览器调用操作 url 时,只有我的控制器断点被触发并且我登陆页面即使我没有经过身份验证..
我做错了什么?
提前致谢。
【问题讨论】:
标签: c# asp.net-mvc custom-attributes onactionexecuting