ASP.NET MVC Interview questions


Total available count: 28
Subject - Microsoft Technologies
Subsubject - ASP.NET MVC

How many types of filters are there in MVC?

There are four types of Filters available in MVC.
a. Authorization filter
b. Action filter
c. Result filter
d. Exception filter

A new filter called Authentication filter was introduced in MVC 6.
Authorization filter:
1. Interface to be implemented -  IAuthorizationFilter
2. Usage - IAuthorizationFilter validates authorization about whether to execute an action method or not and also it validates the properties of the request
3. Methods - OnAuthorization

Action filter:
1. Interface to be implemented -   IActionFilter
2. Usage - IActionFilter Can perform additional operations before and after execution of action methods
3. Methods -  OnActionExecuting, OnActionExecuted

Result filter:
1. Interface to be implemented -  IResultFilter
2. Usage - IResultFilter Can perform additional operations before and after execution of view results
3. Methods - OnResultExecuting, OnResultExecuted

Exception filter:
1. Interface to be implemented -  IExceptionFilter
2. Use - Exception filters will get executed if there is an unhandled exception thrown during the execution of the ASP.NET MVC pipeline. Exception filters can be used for tasks such as logging or displaying an error page
3. Methods - OnException
 




Next 5 interview question(s)

1
What is the difference between ActionResult and ViewResult?
2
What are filters?
3
What is the difference between TempData.Keep() vs TempData.Peek()?
4
What is the use of TempData?
5
What is the difference between ViewData and ViewBag?