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
LLM時代のパフォーマンスチューニング:MongoDB運用で試したコンテキスト活用の工夫
ishikawa_pro
0
170
Codeful Serverless / 一人運用でもやり抜く力
_kensh
7
460
要件定義・デザインフェーズでもAIを活用して、コミュニケーションの密度を高める
kazukihayase
0
120
いま注目のAIエージェントを作ってみよう
supermarimobros
0
360
Django's GeneratedField by example - DjangoCon US 2025
pauloxnet
0
160
実践!カスタムインストラクション&スラッシュコマンド
puku0x
0
550
DroidKaigi 2025 Androidエンジニアとしてのキャリア
mhidaka
2
390
AWSを利用する上で知っておきたい名前解決のはなし(10分版)
nagisa53
10
3.2k
TS-S205_昨年対比2倍以上の機能追加を実現するデータ基盤プロジェクトでのAI活用について
kaz3284
1
230
「その開発、認知負荷高すぎませんか?」Platform Engineeringで始める開発者体験カイゼン術
sansantech
PRO
2
910
今日から始めるAWSセキュリティ対策 3ステップでわかる実践ガイド
yoshidatakeshi1994
0
120
職種の壁を溶かして開発サイクルを高速に回す~情報透明性と職種越境から考えるAIフレンドリーな職種間連携~
daitasu
0
190
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.6k
Designing for Performance
lara
610
69k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
Building Applications with DynamoDB
mza
96
6.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Why Our Code Smells
bkeepers
PRO
339
57k
Site-Speed That Sticks
csswizardry
10
820
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
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