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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tonya Cooper
July 02, 2022
Technology
110
0
Share
Custom Action Filters in ASP.NET MVC
Tonya Cooper
July 02, 2022
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
74
Other Decks in Technology
See All in Technology
互換性のある(らしい)DBへの移行など考えるにあたってたいへんざっくり
sejima
PRO
0
510
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
3
2k
スケーリングを封じられたEC2を救いたい
senseofunity129
0
130
Tour of Agent Protocols: MCP, A2A, AG-UI, A2UI with ADK
meteatamel
0
180
やさしいとこから始めるGitHubリポジトリのセキュリティ
tsubakimoto_s
3
2.1k
RGBに陥らないために -プロダクトの価値を届けるまで-
righttouch
PRO
0
130
スクラムを支える内部品質の話
iij_pr
0
120
開発チームとQAエンジニアの新しい協業モデル -年末調整開発チームで実践する【QAリード施策】-
kaomi_wombat
0
280
脳が溶けた話 / Melted Brain
keisuke69
1
1.2k
LLMに何を任せ、何を任せないか
cap120
11
6.8k
AIにより大幅に強化された AWS Transform Customを触ってみる
0air
0
250
AWS Systems Managerのハイブリッドアクティベーションを使用したガバメントクラウド環境の統合管理
toru_kubota
1
200
Featured
See All Featured
Paper Plane (Part 1)
katiecoart
PRO
0
6.2k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
210
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
270
Making the Leap to Tech Lead
cromwellryan
135
9.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
160
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
150
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
GitHub's CSS Performance
jonrohan
1032
470k
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