Mostly asked MVC interview questions for experienced


  •        What is MVC?

Answer: You can say it’s a design pattern or framework or library.  For any answer you should have a concrete response as we can prove that MVC can be anyone of these [Design Pattern/Library/Framework].

  • .      Why we need MVC, why not only ASP.net?

Answer: Over net you will find the answers like Separation of Concern, Unit Test, TDD [Test driven development] etc.

My Sincere suggestion would be, first you say it is open source and you have lot of option to customize existing MVC components as per your project requirement [Like Custom HTML helper, Custom Validation, Custom Action Result etc.].

Another basic advantage is URL – which you can customize on your own.
For example: http://localhost:80/Employee/Details/5 instead of http://localhost:80/EmployeeDetails.aspx or hide the existing URL through attribute routing [MVC5].  URL works like a sitemap for end user which makes them feel happy.

Performance – as there is no ViewState for any control MVC is lightweight compare to asp.net.

If you have two separate teams (one for UI, another for dot net), both can works parallel without impacting others as there is no strongly coupled component. Like in ASP.net for ‘Button1’ you will have ‘Button1_Click ()’ event.

Compatibility or adaptability with different device and different browsers using multiple option of MVC like Display mode/ ViewPort of @media query, bootstrap etc.

Filters are too easy to work rather than httpHandler or httpmodule.

Support of all modern Plugin/tools like Telerik Kendo UI, Bootstrap, Knockout, angular, node etc.


  •    Can you write a code to have a custom validation?


Answer: Basically interviewer wants to know here whether you know the basic components to write a custom validation or not.
Those are ‘ValidationAttribute’, which you need to inherit/implement into your class and the method which you have to override is ‘IsValid’ which will have multiple overloaded options. If you want to get some another member inside Isvalid method you can use ValidationContext. Sample example you can find here. 1  2  3

  • .      How can you add validation over URL in MVC or how to have Routing constraints?

Answer: Please find the answer here.

  •   For example, inside an Action method in your controller, you will be returning like below. 

If(x == “MainWindow”)
return View(‘Test’,listEmployee);
else if (x==”PartialWindowForFilterData”)
return Json(listEmployee, JsonRequestBehavior.AllowGet);
else
return View();

The above statement is purely valid. Now, what will be the return type of this method ?

Answer : ActionResult. As ‘ActionResult’ is top of all other result type.

  •  How will you create a filter? ( Not specific to authentication/Authorization/Action/Exception).

Answer: Add a folder into your solution, Add a class , inherit ‘filterAttribute’  class into your class, add a entry into FilterConfig.cs inside App Start folder or Global.asax file.

  •         Now how make this filter as global? Or, without mentioning filterAttribute top of every  controllers or every action methods, get the functionality of filter attribute on top of  every controllers.

Answer: Make the same filter you created before as global. How? Inside FilterConfig or Application_Start() of Global.asax like below.
            GlobalFilters.Filters.Add(new MyActionFilterAttribute());
  •              How you create a custom HTML helper? How to make custom HTML helper accessible globally.

Answer: See this Video.


  •       Why we use area in MVC? How you communicate over areas?

Answer: Area got introduced in MVC 2.0. The basic purpose is to separate multiple different sets [controller-model-view] using a block/container called area based on the usability purpose.
For example: Admin may have a set of controller model and view which may not be related much with Normal end user. They can communicate through each other using multiple option like @HTML.ActionLink(“LinkName”, “Contrller”,”Action”,”area”,”htmlAttribute”)

  •       How to customize[Show, hide, segregate ] model properties ?

Answer: you have multiple options to do that.
i)                    Use ScafoldColumn to false to hide a property into view.
ii)                  Use Display(Name = “SomeDifferentName”)
 Over model class to display some different name.
iii)                Use ViewModel.
iv)                Use Bind class.
v)                  Use IModelBinder
Do google, you will get example and solution for each one of the above.


  • How request flow in MVC
Answer: See this Link and this


I will come with few more interview question for experienced in next.



You can follow this for a good reference written by my best mentor. 

Write a method which will take any numbers of input, any type of input and add values of all.


Below is the method which will accept any number of inputs and any type of inputs and add values of all.



Call this method inside yours Static void main like below with any number and any type of parameters.
Here outputs are,  a = 6 , b = abcXYZtest and c = 6.9.