Overall ideas on Filters in MVC
Hi guys! This is my new blog which is on filters in MVC. This is a very good topic for you all so please read the blog carefully till the end and get complete knowledge. So let’s start with the details. You will find action methods in MVC applications and this action method performs the operation only when the user interacts with the user interface. If you want to perform any operation after or before the action method then you have to use filters, because filters use is the only way to performing any kind of post-logic or pre-logic action method for the execution.
Types of filters:
There are normally 4 kinds of filters which are like:
- Authorization filter
- Action filter
- Result filter
- Exception filter
If you are going for security purpose, then you have to use the Authorization filter. This type of filter always executed before all the filters.
This filter works two methods like ON action executing and an action executed. The executing part runs before the action method gets executed and executed part runs after the action method is executed.
This is a special kind of filter which is used for the applying any logic those which are needed to be executed at the time of result execution.
This filter executed at the time of any unhandled exceptions happen at the time of execution of ASP.NET for generating the log and redirecting the error page.
Some predefine filters in MVC:
- Handle Error
- Output Cache
- Require Https
Custom action creation process:
You can easily create a custom action filter, by a class that is inherited by the action filter attribute class. The action filter mainly implemented with two interfaces like my action Result and I action Filter.
Various ways to use action filters:
You can use the action filter mainly 3 ways
- Controller level
- Action level
- Global filter
I just share all my experience and knowledge about filters in MVC and various processes.This is the complete blog so in this blog you guys get information on filters in MVC I will come with a new subject with my next blog. So if you have any doubt regarding this blog you can comment under I will try my best to solve your problems or doubts. To know more information you can visit www.cpd-india.com. CPD Technologies Block C 9/8, Sector – 7, Rohini, Delhi – 110085, India Landmark: Near Rohini East Metro Station, Opposite Metro Pillar No-397. For free demo class you can call at-011-65164822/91-8860352748. For any suggestion free feels to email at firstname.lastname@example.org.