我使用类名 RightCheckerAttribute 来检查 MVC3 应用程序中的用户权限......所以 RightCheckerAttribute 类是这样的......
public bool isAdmin { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
HttpContextBase context = filterContext.HttpContext;
bool result = Convert.ToBoolean(context.Request.QueryString["isAdmin"].ToString());
if (isAdmin != result)
{
RouteValueDictionary redirecttargetDictionary = new RouteValueDictionary();
redirecttargetDictionary.Add("action", "NoPermission");
redirecttargetDictionary.Add("controller","Singer");
filterContext.Result = new RedirectToRouteResult(redirecttargetDictionary);
}
//base.OnActionExecuting(filterContext);
}
所以在我应用这个的方法中,头是..
[RightChecker (isAdmin=true)]
我正在执行这个方法。
http://localhost:5576/Singer/DeleteSinger?isAdmin=true
问题是我传递的是真还是假......我得到的结果变量为假......而且我得到:
异常[空对象引用]...