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
72
Other Decks in Technology
See All in Technology
AWSの新機能をフル活用した「re:Inventエージェント」開発秘話
minorun365
2
520
"人"が頑張るAI駆動開発
yokomachi
1
660
ESXi のAIOps だ!2025冬
unnowataru
0
440
Strands Agents × インタリーブ思考 で変わるAIエージェント設計 / Strands Agents x Interleaved Thinking AI Agents
takanorig
6
2.4k
SES向け、生成AI時代におけるエンジニアリングとセキュリティ
longbowxxx
0
250
アラフォーおじさん、はじめてre:Inventに行く / A 40-Something Guy’s First re:Invent Adventure
kaminashi
0
190
AWSインフルエンサーへの道 / load of AWS Influencer
whisaiyo
0
240
_第4回__AIxIoTビジネス共創ラボ紹介資料_20251203.pdf
iotcomjpadmin
0
160
投資戦略を量産せよ 2 - マケデコセミナー(2025/12/26)
gamella
0
540
[Neurogica] 採用ポジション/ Recruitment Position
neurogica
1
140
フィッシュボウルのやり方 / How to do a fishbowl
pauli
2
430
通勤手当申請チェックエージェント開発のリアル
whisaiyo
3
620
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
Color Theory Basics | Prateek | Gurzu
gurzu
0
160
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
0
100
Skip the Path - Find Your Career Trail
mkilby
0
28
Building Adaptive Systems
keathley
44
2.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
WENDY [Excerpt]
tessaabrams
9
35k
Exploring anti-patterns in Rails
aemeredith
2
210
Paper Plane (Part 1)
katiecoart
PRO
0
2.4k
Everyday Curiosity
cassininazir
0
110
Believing is Seeing
oripsolob
0
18
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
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