定义过滤类:

public class TestFilter : ActionFilterAttribute
{
/// <summary>
/// 行为执行前
/// </summary>
/// <param name="filterContext"></param>
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//ToDoing
if (filterContext.ActionDescriptor.ActionName.ToLower() == "testList".ToLower())
{
if (true)
{
filterContext.HttpContext.Response.Write("您没有权限操作!");
filterContext.HttpContext.Response.End();
}
}
base.OnActionExecuting(filterContext);
}
}


控制器中使用:

[TestFilter]
public class AuditPayExpenseController : Controller     
{
     public ActionResult testList(int? pagerIndex, FormCollection collenct)
{

return View();
}
}

 

 

 

相关文章:

  • 2022-01-31
  • 2021-05-25
  • 2022-02-27
  • 2022-12-23
  • 2022-02-09
  • 2022-01-05
  • 2022-02-09
猜你喜欢
  • 2021-09-12
  • 2021-06-28
  • 2021-11-16
  • 2022-02-09
  • 2021-10-18
  • 2021-06-21
  • 2021-11-24
相关资源
相似解决方案