gri*_*egs 13 c# parameters asp.net-mvc action-filter actionfilterattribute
我有一个ActionFilterAttribute我想接受参数通过但我无法弄清楚它们通过它们.
所以我的动作过滤器看起来像这样;
public class PreventAction : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.Result = new RedirectResult("Home/Index");
}
}
Run Code Online (Sandbox Code Playgroud)
我这样装饰我的动作;
[PreventAction]
public ActionResult Ideas()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
现在我想添加一个参数,以便我可以像这样调用过滤器;
[PreventAction(myParam1 = "1", myParam2 = "2")]
public ActionResult Ideas()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
有人知道怎么做吗?