执行code控制器的方法之前被调用? [英] Executing code before a controller's method is invoked?

查看:113
本文介绍了执行code控制器的方法之前被调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使一个行为过滤器或者一些运行的之前的操作方法本身的控制器上运行?

Is it possible to make an action filter or something that runs before the action method itself runs on the controller?

我需要的操作运行在此之前,分析请求数的值。

I need this to analyze a few values in the request before the action runs.

推荐答案

您可以覆盖OnActionExecuting在控制器类方法

You can override OnActionExecuting method in controller class

protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
        base.OnActionExecuting(filterContext);
//Your logic is here...
}

这篇关于执行code控制器的方法之前被调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆