Search This Blog

Sunday, July 14, 2019

Fiter in MVC

Filters are attribute which  are used to perform some logic before and  after a Action Method is called
e.g
caching ,error handling,logging,permision many more etc
MVC  4 has four filter
MVC 5 has 5 filter

  • Authentication filter
  • Authorization filter
  • Action filter
  • Result filter
  • Exception filter
 Note  this  is also order of execution of filter
Can  we create own filters
Yes
There are three place where we can use filters  in  asp.net mvc

  • Action Method   : Any Filter apply Action method  work  only this filters
  • Controller : Filter may apply  Controler apply all Action Method  with in Controller
  • Global  Apply all Controller global.asax file

Authentication Filters

Authentication filter runs before any other filter or action method. Authentication confirms that you are a valid or invalid user

Authorization Filters

Authorization Filters are responsible for checking User Access

Action Filters 

Action Filter is an attribute that you can apply to a controller action or an entire controller

Result Filters

These filters contains logic that is executed before and after a view result is executed

ExceptionFilters




No comments :