Interview Questions.

MVC Interview Questions and Answers For 2 Years Experience


MVC Interview Questions and Answers For 2 Years Experience

Q1. What do you meant MVC?

Ans: MVC is a framework sample that splits an software’s implementation common sense into

three thing roles: fashions, views, and controllers.

Model: The enterprise entity on which the general software operates. Many applications use a continual garage mechanism (inclusive of a database) to shop information. MVC does no longer especially point out the facts get right of entry to layer due to the fact it's miles understood to be encapsulated by way of the Model.

View: The user interface that renders the Model into a form of interaction.

Controller: Handles a request from a View and updates the Model that effects in a exchange of the Model's nation.

To implement MVC in .NET we need especially 3 instructions (View, Controller and the Model).

Q2. What is supposed by ASP.Net MVC

Ans: The ASP.Net MVC is the framework provided by Microsoft to acquire     separation of issues that results in clean maintainability of the     utility.

Model is meant to handle statistics related activity

View offers with consumer interface related paintings

Controller is meant for dealing with the application waft with the aid of speaking among Model and View.

Q3. What are the brand new features of MVC2?

Ans: ASP.NET MVC 2 changed into launched in March 2010. Its fundamental capabilities are:

Introduction of UI helpers with automated scaffolding with customizable templates.

Attribute-primarily based model validation on each patron and server.

Strongly typed HTML helpers.

Improved Visual Studio tooling

There were also lots of API upgrades and “pro” functions, primarily based on remarks from developers building an expansion of applications on ASP.NET MVC 1, consisting of:

 Support for partitioning huge applications into

 Asynchronous controllers support.

 Support for rendering subsections of a web page/website online the use of Html.RenderAction.

 Lots of recent helper functions, utilities, and API upgrades

Q4. Explain “page lifecycle” of an ASP.NET MVC?

Ans: Following system are executed by ASP.Net MVC web page:

App initialization


Instantiate and execute controller

Locate and invoke controller motion

Instantiate and render view

Q5. What are the brand new functions of MVC3?

Ans: ASP.NET MVC three shipped just 10 months after MVC 2 in Jan 2011.Some of the pinnacle functions in MVC three protected:

     The Razor view engine.

     Support for .NET 4 Data Annotations.

     Improved version validation

     Greater manipulate and versatility with help for dependency decision and international movement filters.

     Better JavaScript aid with unobtrusive JavaScript, jQuery Validation, and JSON binding.

     Use of NuGet to supply software program and manipulate dependencies for the duration of the platform.

Q6. What are the new features of MVC4?

Ans: Following are the pinnacle features of MVC4:

    NET Web API.

    Enhancements to default challenge templates.

    Mobile venture template the usage of jQuery Mobile.

    Display Modes.

    Task support for Asynchronous Controllers.

    Bundling and minification.

Q7. Why to use ASP.Net MVC

Ans: The strength of MVC (i.E. ASP.Net MVC) is indexed under, with a view to solution this query

MVC reduces the dependency among the components; this makes your code more testable.

MVC does now not propose use of server controls, for this reason the processing time required to generate HTML response is notably decreased.

The integration of java script libraries like jQuery, Microsoft MVC will become clean compared to Webforms approach.

Q8. Advantages of MVC Framework?

Provides a easy separation of concerns among UI (Presentation layer), model (Transfer items/Domain Objects/Entities) and Business Logic (Controller).

Easy to UNIT Test.

Improved reusability of perspectives/version. One may have a couple of views which can point tosame model and vice versa.

Improved structuring of the code.

Q9. What do you imply by means of Razor

Ans: The Razor is the new View engine added in MVC three.0.

The View engine is chargeable for processing the view documents [e.G. .Aspx, .Cshtml] in an effort to generate HTML reaction.

The previous variations of MVC have been dependent on ASPX view engine.

HubSpot Video


Q10. What do you imply by way of Separation of Concerns?

Ans: As according to Wikipedia 'the technique of breaking a pc software into distinct functions that overlap in functionality as low as viable'. MVC layout pattern pursuits to separate content from presentation and information-processing from content material.

Q11. Can we use ASPX view engine in modern-day versions of MVC

Ans: Yes. The Recommended way is to choose Razor View

Q12. Where will we see Separation of Concerns in MVC?

Ans: Between the facts-processing (Model) and the rest of the utility.

When we speak about Views and Controllers, their ownership itself explains separation. The views are just the presentation form of an software, it does no longer need to know especially about the requests coming from controller. The Model is unbiased of View and Controllers, it simplest holds enterprise entities that may be handed to any View through the controller as required for exposing them to the cease person. The controller is unbiased of Views and Models, its sole reason is to address requests and skip it on as according to the routes described and as in keeping with the want of rendering views. Thus our enterprise entities (model), business good judgment (controllers) and presentation good judgment (views) lie in logical/bodily layers independent of each other.

Q13. What are the benefits of Razor View?

Ans: The syntax for server side code is simplified

The length of code is significantly decreased

Razor syntax is easy to research and reduces the complexity

Q14. What is the extension of Razor View file?

Ans: .Cshtml (for c#) and .Vbhtml (for vb)

Q15. What are Display Modes in MVC4?

Ans: Display modes use a conference-primarily based technique to permit deciding on different perspectives based totally on the browser making the request. The default view engine fi rst appears for views with names ending with .Mobile.Cshtml when the browser’s consumer agent shows a recognized cellular device. For example, if we have a conventional view titled Index.Cshtml and a cellular view titled Index.Mobile.Cshtml, MVC four will automatically use the mobile view whilst regarded in a mobile browser.

Additionally, we will sign in your personal custom tool modes that will be primarily based for your very own custom criteria — all in just one code assertion. For instance, to sign up a WinPhone device mode that would serve views finishing with .WinPhone.Cshtml to Windows Phone devices, you’d use the following code within the Application_Start approach of your Global.Asax:

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("WinPhone")

ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf

("Windows Phone OS", StringComparison.OrdinalIgnoreCase) >= zero)


Q16. How to create a Controller in MVC

Ans: Create a simple class and expand it from Controller class. The naked minimum requirement for a class to become a controller is to inherit it from ControllerBase is the elegance this is required to inherit to create the controller however Controller magnificence inherits from ControllerBase.

Q17. What is AuthConfig.Cs in MVC4?

Ans: AuthConfig.Cs  is used to configure safety settings, along with web sites for OAuth login.

Q18. How to create an Action method in MVC

Ans: Add a easy method internal a controller magnificence with ActionResult go back kind.

Q19. How to get right of entry to a view at the server 

Ans: The browser generates the request in which the statistics like Controller name, Action Name and Parameters are provided, whilst server receives this URL it resolves the Name of Controller and Action, after that it calls the required movement with provided parameters. Action typically does a few processing and returns the ViewResult by way of specifying the view call (clean name searches in line with naming conventions).

Q20. What is the default Form approach (i.E. GET, POST) for an action method

Ans: GET. To exchange this you could add an action stage attribute e.G [HttpPost]