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
32
Tools & Strategies for Consuming APIs V1
tonyazen
0
60
Testing_the_Endpoints_of_Your_REST_APIs.pdf
tonyazen
0
70
Other Decks in Technology
See All in Technology
成長し続けるアプリのためのテストと設計の関係、そして意思決定の記録。
sansantech
PRO
0
120
使いたいMCPサーバーはWeb APIをラップして自分で作る #QiitaBash
bengo4com
0
2k
データグループにおけるフロントエンド開発
lycorptech_jp
PRO
1
110
生まれ変わった AWS Security Hub (Preview) を紹介 #reInforce_osaka / reInforce New Security Hub
masahirokawahara
0
480
PO初心者が考えた ”POらしさ”
nb_rady
0
210
2025-07-06 QGIS初級ハンズオン「はじめてのQGIS」
kou_kita
0
170
american aa airlines®️ USA Contact Numbers: Complete 2025 Support Guide
aaguide
0
210
Delegating the chores of authenticating users to Keycloak
ahus1
0
140
生成AI開発案件におけるClineの業務活用事例とTips
shinya337
0
260
関数型プログラミングで 「脳がバグる」を乗り越える
manabeai
1
190
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
10
130k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
960
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.5k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Designing for Performance
lara
610
69k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
The Language of Interfaces
destraynor
158
25k
The Straight Up "How To Draw Better" Workshop
denniskardys
234
140k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Done Done
chrislema
184
16k
Producing Creativity
orderedlist
PRO
346
40k
Optimizing for Happiness
mojombo
379
70k
Making the Leap to Tech Lead
cromwellryan
134
9.4k
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