ASP.NET MVC Action Filters
在看这篇Fun with Http Headers in ASP.NET MVC Action Filters的时候,提到了 Roni Schuetz在codeplex上创建的一个项目ASP.NET MVC Action Filters。计划在5月10日推出第一个版本。 项目计划包含的Action Filter:
- Action filter for creating easy REST API with JSON and XML
- Action filter for logging scenarios
- Action filter for microsoft health monitoring
- Action filter for client caching
- Action filter for client compression
- Action filter for server caching
- Action filter for controller execution time measurement
简要介绍一下Action Filter:Action Filter作为一个可以应用到Controller Action(或者是整个controller)上的属性(Attribute),改变Action执行的行为。ASP.NET MVC Framework包括几种Action Filter:
- OutputCache – 在指定的时间内缓存Controller Action的输出。
- HandleError – 处理Controller Action发生错误的情况。
- Authorize – 通过制定的用户或者角色约束访问权限。
你同时可以创建自己的Action Filter,比如说要实现一个自定义的验证系统,那么可能需要创建一个自定义的Action Filter,或者说当你需要改变Controller Action返回的View data的时候,也可以通过创建自定义Action Filter实现。
关于Action Filter的具体内容可参考 理解ASP.NET MVC Framework Action Filters(翻的)。
欢迎大家扫描下面二维码成为我的客户,扶你上云

【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步