ASP.Net MVC Interview Questions Objective: Part 1

In this article we will discuss ASP.NET MVC Interview Questions. We are focusing on Objective Questions that can be asked in an interview.

Since we are talking about MVC we should have some knowledge of MVC.

Objective Interview Questions on ASP.NET MVC

Question 1: What does MVC stand for>


Answer: Model-View-Controller.

Question 2: What are three main components or aspects of MVC?

Answer: Model-View-Controller

Question 3: Which namespace is used for ASP.NET MVC? Or which assembly is used to define the MVC framework?

Answer: System.Web.Mvc

Question 4: What is the default view engine in ASP.NET MVC?

Answer: Web Form(ASPX) and Razor View Engine.

Question 5: Can we remove the default View Engine?

Answer: Yes, by using the following code:

  1. protected void Application_Start()  
  2. {  
  3.       ViewEngines.Engines.Clear();  

Question 6: Can we have a Custom View Engine?

Answer: Yes, by implementing the IViewEngine interface or by inheriting from the VirtualPathProviderViewEngine abstract class.

Question 7: Can we use a third-party View Engine?

Answer: Yes, ASP.NET MVC can have Spark, NHaml, NDjango, Hasic, Brail, Bellevue, Sharp Tiles, String Template, Wing Beats, SharpDOM and so on third-party View Engine.

Question 8: What are View Engines?

Answer: View Engines are responsible for rendering the HTML from your views to the browser.

Question 9: What is Razor Engine?

Answer: The Razor view engine is an advanced view engine from Microsoft, packaged with MVC 3. Razor uses an @ character instead of aspx's <% %> and Razor does not require you to explicitly close the code-block.

Question 10: What is scaffolding?

Answer: Quickly generating a basic outline of your software that you can then edit and customize.

Question 11: What is the name of Nuget scaffolding package for ASP.NET MVC3 scaffolding?

Answer: MvcScaffolding

Question 12: Can we share a view across multiple controllers?

Answer: Yes, it is possible to share a view across multiple controllers by putting a view into the shared folder.

Question 13: What is unit testing?

Answer: The testing of every smallest testable block of code in an automated manner. Automation makes things more accurate, faster and reusable.

Question 14: Is unit testing of MVC application possible without running the controller?

Answer: Yes, by the preceding definition.

Question 15: Can you change the action method name?

Answer: Yes, we can change the action method name using the ActionName attribute. Now the action method will be called by the name defined by the ActionName attribute.

  1. [ActionName("DoAction")]  
  2. public ActionResult DoSomething()  
  3. {  
  4.       /TODO:  
  5.       return View();  
  6. }  

Question 16: How to prevent a controller method from being accessed by an URL?

Answer: By making the method private or protected but sometimes we need to keep this method public. This is where the NonAction attribute is relevant.

Question 17: What are the features of MVC5?

Answer:

  • Scaffolding
  • ASP.NET Identity
  • One ASP.NET
  • Bootstrap
  • Attribute Routing
  • Filter Overrides

Question 18: What are the various types of filters in an ASP.NET MVC application?

Answer:

  • Authorization filters
  • Action filters
  • Result filters
  • Exception filters

Question 19: If there is no match in the route table for the incoming request's URL, which error will result?

Answer: 404 HTTP status code

Question 20: How to enable Attribute Routing?

Answer: By adding a Routes.MapMvcAttributeRoutes() method to the RegisterRoutes() method of the RouteConfig.cs file.

I think 20 questions are enough for one day.

Your comments and suggestions are always welcomed.

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now