Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Custom Action Filters in ASP.NET MVC
Search
Tonya Cooper
July 02, 2022
Technology
0
110
Custom Action Filters in ASP.NET MVC
Tonya Cooper
July 02, 2022
Tweet
Share
More Decks by Tonya Cooper
See All by Tonya Cooper
Tools & Strategies for Consuming APIs
tonyazen
0
34
Tools & Strategies for Consuming APIs V1
tonyazen
0
61
Testing_the_Endpoints_of_Your_REST_APIs.pdf
tonyazen
0
73
Other Decks in Technology
See All in Technology
Why Organizations Fail: ノーベル経済学賞「国家はなぜ衰退するのか」から考えるアジャイル組織論
kawaguti
PRO
1
180
We Built for Predictability; The Workloads Didn’t Care
stahnma
0
150
ECS障害を例に学ぶ、インシデント対応に備えたAIエージェントの育て方 / How to develop AI agents for incident response with ECS outage
iselegant
3
290
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
93k
ランサムウェア対策としてのpnpm導入のススメ
ishikawa_satoru
0
220
ブロックテーマ、WordPress でウェブサイトをつくるということ / 2026.02.07 Gifu WordPress Meetup
torounit
0
200
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
5.6k
私たち準委任PdEは2つのプロダクトに挑戦する ~ソフトウェア、開発支援という”二重”のプロダクトエンジニアリングの実践~ / 20260212 Naoki Takahashi
shift_evolve
PRO
2
190
SchooでVue.js/Nuxtを技術選定している理由
yamanoku
3
200
OpenShiftでllm-dを動かそう!
jpishikawa
0
140
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
770
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
1k
Featured
See All Featured
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
110
From π to Pie charts
rasagy
0
130
Agile that works and the tools we love
rasmusluckow
331
21k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
The Mindset for Success: Future Career Progression
greggifford
PRO
0
240
A Tale of Four Properties
chriscoyier
162
24k
GraphQLとの向き合い方2022年版
quramy
50
14k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
190
Google's AI Overviews - The New Search
badams
0
910
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Exploring anti-patterns in Rails
aemeredith
2
250
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
190
Transcript
Custom Action Filters in ASP.NET MVC
What are action filters? An attribute that can be applied
to an individual action method on a controller, or to the entire controller.
Filter Types 1. Authorize 2. Action 3. Result 4. Exception
Built-in Filter Attributes Authorize HandleError RequireHttps ValidateInput OutputCache
ActionFilterAttribute IAuthorizationFilter IActionFilter IResultFilter IExceptionFilter HandleError RequireHttps Authorize OutputCache ValidateInput
FilterAttribute
ActionFilterAttribute IAuthorizationFilter IActionFilter IResultFilter IExceptionFilter HandleError RequireHttps Authorize OutputCache ValidateInput
FilterAttribute
ActionFilterAttribute IAuthorizationFilter IActionFilter IResultFilter IExceptionFilter HandleError RequireHttps Authorize OutputCache ValidateInput
FilterAttribute
Built-in Filter Attributes Authorize HandleError RequireHttps ValidateInput OutputCache
None
Built-in Filter Attributes Authorize HandleError RequireHttps ValidateInput OutputCache
Turn on custom errors in Web.config: FilterConfig.cs
Global.asax
Built-in Filter Attributes Authorize HandleError RequireHttps ValidateInput OutputCache
None
Built-in Filter Attributes Authorize HandleError RequireHttps ValidateInput OutputCache
None
Built-in Filter Attributes Authorize HandleError RequireHttps ValidateInput OutputCache
None
Custom Filters • Share code across action methods • Share
code across controllers • Custom exception handling • Logging • Modify responses • Save responses
ActionFilterAttribute Override Methods: 1. OnActionExecuting 2. OnActionExecuted 3. OnResultExecuting 4.
OnResultExecuted
Action Filters… In Action
Start Filtering 1. Name your filters appropriately
CustomFilter is NOT a good name.
Start Filtering 1. Name your filters appropriately 2. Apply to
one or more action
Start Filtering 1. Name your filters appropriately 2. Apply to
one or more action 3. Apply to one or more controller
Start Filtering 1. Name your filters appropriately 2. Apply to
one or more action 3. Apply to one or more controller 4. Apply globally
FilterConfig.cs
Start Filtering 1. Name your filters appropriately 2. Apply to
one or more action 3. Apply to one or more controller 4. Apply globally 5. Specify the order
None
Custom Action Filters in ASP.NET MVC