Books MVC ASP.NET C# SQL Server WCF Written Test HR Round Subscribe C# Videos C# Programs Buy DVD

Wednesday, November 23, 2011

MVC Interview Questions on Filters

What is the use of action filters in an MVC application?
Action Filters allow us to add pre-action and post-action behavior to controller action methods.

If I have multiple filters impleted, what is the order in which these filters get executed?
1. Authorization filters
2. Action filters
3. Response filters
4. Exception filters


What are the different types of filters, in an asp.net mvc application?
1. Authorization filters
2. Action filters
3. Result filters
4. Exception filters

Give an example for Authorization filters in an asp.net mvc application?
1. RequireHttpsAttribute
2. AuthorizeAttribute

Which filter executes first in an asp.net mvc application?
Authorization filter

What are the levels at which filters can be applied in an asp.net mvc application?
1. Action Method
2. Controller
3. Application


Is it possible to create a custom filter?
Yes

What filters are executed in the end?
Exception Filters

Is it possible to cancel filter execution?
Yes

What type of filter does OutputCacheAttribute class represents?
Result Filter

5 comments:

  1. How can we cancel the filter execution?

    ReplyDelete
    Replies
    1. public class SignInRequiredAttribute : AuthorizeAttribute
      {
      protected override bool AuthorizeCore(HttpContextBase httpContext)
      {
      return !Acme.Web.CurrentUser != null;
      }
      }

      Delete
  2. Action filter pre and post behavour

    ReplyDelete
  3. How can we cancel the filter execution..................?
    and how to work in application level filters..............?

    ReplyDelete
  4. How can we cancel the filter execution..................?
    and how to work in application level filters..............?

    ReplyDelete

 
Disclaimer - Terms of use - Contact Us