QA-MVC ASP.Net

In this article,  explaining best MVC ASP.Net Interview Questions and Answers as following:

Q.What is ActionResult() ?

Ans: It is an abstract Class

Q.What is ViewResult() ?

Ans: It is a Concrete Class

Q. MVC return View() works like?

Ans: Server.Transfer()

Q. MVC RedirectToAction() works like?

Ans: Response.Redirect()

Q. Can we use view state in MVC ?

Ans: No

Q. What Request Processing technique follows ASP.Net ?

Ans: Pipeline

Q. What is DRY principle in ASP.Net ?

Ans: Don’t repeat yourself(DRY)
Q. What is default authentication in Internet Information Services (IIS)?

Ans: Anonymous

Q. What is the extension of MVC view when using C#?

Ans: cshtml

Q. What is the extension of MVC view when using vb.net?

Ans: vbhtml

Q. How can you comment using Razor Syntax?

Ans: @* Comment me *@

Q. Which Namespace is used for Razor View Engine ?

Ans: System.Web.Razor

Q. Which Namespace is used for ASPX View Engine ?

Ans: System.Web.Mvc.WebFormViewEngine

Q. The Razor View Engine uses to render server side content.

Ans: @

Q. The ASPX View Engine uses to render server side content.

Ans: <%= %>

Q. Which is more faster between ASPX View Engine and Razor View Engine.

Ans: ASPX View Engine

Q. Does Razor Engine supports for TDD ?

Ans: Yes

Q. Does ASPX View Engine supports for TDD ?

Ans: No

Q. How to Print value from Controller to View in MVC ?

Ans: ViewBag.MyName = “Shashangka”; and in view .MyName

Q. What are the advantages of using ASP.NET routing?

Ans: Clean URLs is originally brought from Ruby on Rails.

Q. What is the significance of ASP.NET routing?

Ans: Default Route Name:
“{controller}/{action}/{id}”, // URL with parameters
By default routing is defined under Global.asax file. MVC ASP.Net uses routing to map between incoming browser request to controller action methods.

Q. Can be it possible to share single view across multiple controllers in MVC?

Ans: We can put the view under shared folder, it will automatically view the across the multiple controllers.

Q. Are MVC and Web API merged into one in MVC 6?

Ans: Yes

Q. Does MVC 6 introduced new JSON project based structure?

Ans: Yes

Q. Does MVC 6 allow only save change, hitting the save but then refreshing the browser to reflect changes?

Ans: Yes

Q. Does vNext is now Open Sourced via the .NET Foundation and open to public contributions.

Ans: Yes

Q. Can vNext runs on both Mac and Linux today (Mono Version)?

Ans: Yes

Q. What is the difference between MVC (Model View Controller) and MVP (Model View Presenter)?

Ans: MVC controller handles all the requests, MVP handles as the handler and also handles the all requests as well.

Q. How does work Viewstart in MVC (ASP.Net)?

Ans:

  1. Viestart is used to layout of the application.
  2. Viewstart is used like Masterpage in traditional forms (ASP.Net pages).
  3. Viewstart render first in the views.

Code Snippet

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

Q. Viewstart comes under which folder name ?

Ans: Views

Q. Does Viewstart override all Views layout/template under “Views” folder in MVC ?

Ans: Yes

Q. What is the name of default Viewstart Page in ASP.Net MVC ?

Ans: _ViewStart.cshtml

Q. Can we use third party View Engine using ASP.Net MVC Engine ?

Ans: Yes, below are the top five alternative ASP.Net MVC View Engines.

  1. Spark (Castle MonoRail framework projects), Open Sourced, it is popular as MVCContrib library.
  2. NHaml works like inline page templating.
  3. NDjango uses F# Language.
  4. Hasic uses VB.Net, XML.
  5. Bellevue for ASP.NEt view, It respects HTML class first.

Q. What is scaffolding using ASP.Net MVC Engine? 

Ans: Scaffolding helps us to write CRUD operations blend using Entity Framework, It helps developer to write down simply even yet complex business logic.

Q. What is life cycle in ASP.Net MVC Engine?

Ans:

  • Step 1: Fill Route (Global.asax file will hit first).
  • Step 2: Fetch Route: It will gether information about controller and action to invoke.
  • Step 3: Request context
  • Step 4:  Controller instance: it calls Controller class and method.
  • Step 5: Executing Action: It determines which action to be executed 
  • Step 6: Result (View): Now Action method executed and returns back response to view in differentiating forms like Json, View Result, File Result etc.

Q. Which is the way to render Partial View using ASP.Net MVC Razor Engine?

Ans: .Partial(“_PartialHeader”)

Q. Which  Namespace is used to “Display” in Data Annotation using MVC ?

Ans: System.ComponentModel

Q. Which  Namespaces are required to Data Annotation using MVC ?

Ans: 

  1. System.ComponentModel
  2. System.ComponentModel.DataAnnotations

Q. Are both TempData/ViewData require typecasting in MVC?

Ans: Both (TempData/ViewData) requires type casting to avoid null exception.

Q. Is ViewBag slower than ViewData in MVC?

Ans: Yes

Q. Is ViewData faster than ViewBag in MVC?

Ans: Yes

Q. Are both TempData/ViewData property of Controller base class in MVC?

Ans: Yes

Q. Does TempData used to pass data from one page to another page in MVC?

Ans: Yes

Q. Can ASP.Net Web API specialize to XML or JSON ?

Ans: Yes

Source: Internet

Author:

Since March 2011, have 8+ years of professional experience on software development, currently working as Senior Software Engineer at s3 Innovate Pte Ltd.

Leave a Reply