创建自定义过滤器并覆盖OnActionExecuting()
:
public class CustomActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
}
}
或者只是OnActionExecuting()
在您的控制器中覆盖
更新:
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
var actionName = filterContext.ActionDescriptor.ActionName;
if(String.Compare(actionName, "Some", true) == 0 && Request.HttpMethod == "POST")
{
var form = filterContext.ActionParameters["form"] as FormCollection;
form.Add("New", "NewValue");
}
}
public ActionResult SomeAction(FormCollection form)
{
...
}