.net – 为所有操作调用ActionFilterAttribute
发布时间:2020-12-16 06:30:27 所属栏目:asp.Net 来源:网络整理
导读:也许我误解了ActionFilterAttribute的观点,但我现在所拥有的是以下内容: public class MyCustomAttribute : ActionFilterAttribute{ public override void OnActionExecuting(ActionExecutingContext filterContext) { //do something useful here }} 然后
也许我误解了ActionFilterAttribute的观点,但我现在所拥有的是以下内容:
public class MyCustomAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { //do something useful here } } 然后在我的Home控制器中,我有以下操作方法: public class HomeController : Controller { public ActionResult Index() { return View(); } [MyCustom] public ActionResult Test() { return View(); } } 我现在期望OnActionExecuting在我尝试访问/ Home / Test时被触发,但在我尝试访问/ Home / Index时却没有. 但是,它会被两个动作方法触发.我还在OnActionExecuting内部验证了实际上正在调用的Index动作. 当您调用标记有属性的操作方法时,是否有可能只调用OnActionExecuting? 解决方法
检查Global.asax中的GlobalFilters集合中是否存在MyCustomAttribute.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 为mp3下载添加水印
- Safari和Asp.net中的cookie存在奇怪的问题
- asp.net-mvc – Jasmine在一个单独的测试项目中
- asp.net – 如何在转发器中每行显示x个项目?
- 适用于ASP.NET Core 2的MultipartFormDataStreamProvider
- asp.net-mvc-4 – 在VS2012中运行代码分析时出错
- asp.net – 什么是DefaultWsdlHelpGenerator.aspx?
- 加快ASP.NET中的构建时间
- asp.net-mvc – 单元测试Url.Action(使用Rhino Mocks?)
- 将webforms混合到ASP.NET MVC应用程序中的问题
推荐文章
站长推荐
热点阅读