MVC tagged Questions - Page 1

What are Razor engines? How is it different from ASP Engines

RAZOR engine is the
new concept in the MVC 3 which is mainly used to create the views in the MVC
applications. It created the cshtml pages for the MVC application and cshtml
pages can be generated automatically by using the Razor engine.ASP engine
create the aspx pages while Razor engine creates the pages.

What is MVC?

MVC (Model View Controller) is one of the Software Architectural pattern which is built on 3 layers. So it is the pattern which basically talks about the separation of concern for a project. Here the 3 parts are having their own roles like:

  • Model - It is used as the Data Container or it can also have the business rules, functions, logic's etc.
  • View - It is mainly the UI (User Interface) part which is the main application built using the Web technologies like ASP.Net etc. It consists of the User Interface Design, representation of the information for the end users etc.
  • Controller - It is the mediator between the View and Model and used to control the requests and responses floating through the views and Model. The command, Actions, Events are the part of Controller in MVC. All the communication is done via Controller so we can say that Controller is the heart of MVC.

What are the new features of ASP.Net MVC 2?

There are few major changes happened in the
version MVC2. The Microsoft has more concentrated on the HTML Helpers,
Validations support, Async controllers etc.

Below are the few points which
distinguishes the ASP.Net MVC 2 different than the previous versions:

  1. New HTML Helpers with Strongly Typed
  2. Model based validations- This is very useful feature where the validation is
    done in the Model and will be used throughout the application.
  3. Automatic scaffolding feature also got introduces with this version.
  4. Asynchronous controller support which enables the multiple tasks to run
  5. Html.RenderAction introduced to render the section/part of the page.

What is ASP.Net MVC?

ASP.Net MVC is the Microsoft product
based on the core MVC pattern. The Microsoft has taken the core concept of MVC
and Designed the ASP.Net MVC structure for the Visual Studio which helps
the developers to get the automated structure and on it, they can
built the applications.

ASP.Net MVC provides
the structure with the separation of concerns where each
part of ASP.Net MVC application is separate and has no link among
them. Apart from the separation of concerns, the Microsoft has provided the way
to communicate between the separate components by using the other
additional logic and libraries. These libraries supports in the connection,
communication between the components, databases and other
external components as well with small effort.

What are the new features of ASP.Net MVC 3?

  1. Scaffolding option for the speedup process
  2. Razor engine with the new razor syntax for good readability of the View code.
  3. HTML 5 support
  4. Model based validations
  5. Model Binders to bind the model with View
  6. Action filters
  7. Nuget enabled
  8. Output caching for partial page

What are the new features of ASP.Net MVC 4?

  1. Mobile support by adding a new Mobile Project template
  2. Web API added for the HTTP requests
  3. Task class support with Async methods
  4. Bundling and Magnification
  5. Login with the social networking websites
  6. Support of Windows Azure SDK
  7. Display modes for the webpage and mobile layout page

What are the new features of ASP.Net MVC 5?

  1. One ASP.Net for all type of Web templates
  2. Bootstrap enabled for the MVC 5
  3. New Authentication Filter for Controller/Controllers
  4. Attribute Routing
  5. New Scaffolding option
  6. Filter overrides feature

life cycle of mvc

The application life cycle of MVC includes the request, processing, filtering and execution and then finally the response back to the requester. The request first goes to URL routing module(HTTP Module) and there it gets decided that whether this is MVC request and will be handled or not. Now if the request is for MVC application, the URL routing module selects the first route which is satisfying the requested URL. As soon as the first match found for the requested URL, the process for the execution begins with the Controller and Model(if any) and the response sends back to the browser.

advantages of MVC framework

The following are the advantages of MVC framework:

  1. Separation of Concerns
  2. Light weight
  3. No round trip for the layers
  4. Decoupling between the layers
  5. No dependencies between the Model, View and Controller 

What is Razor View Engine in ASP.Net MVC 3?

Razor View engine is the new engine which the Microsoft has introduces with the ASP.Net MVC 3. So from MVC 3 onward, we can see the MVC application will support ASPX as well as Razor view engine. So when we use .aspx to develop our Views, it will use the ASPX engine to execute and when we use the Razor Views(.cshtml or .vbhtml), then it will use the Razor view engine to execute them.

What are the difference between asynchronous controller implementation between ASP.NET MVC 3 and ASP.NET MVC 4?

There is major difference is on implementation mechanism between ASP.NET MVC 3 and ASP.NET MVC 4.

In ASP.NET MVC 3, to implement async controller or methods we need to derive controller from AsyncController rather than from normal plain Controller class. We need to create 2 action methods rather than one. First with suffix  ‘Async’ keyword & second with ‘Completed’ suffix.

In  ASP.NET MVC 4 you need not to declare 2 action method. One can serve the purpouse. MVC 4 using .Net Framework 4.5 support for asynchronous communication.

What is new in MVC 4?

  1. Easy Mobile web applications (ASP.NET MVC 4 complete focus on Mobile application development)
  2. Full HTML5 support
  3. ASP.NET MVC web application with cloud support
  4. Working with different mobile and desktop web browsers

The main objective of ASP.NET MVC 4 is making to develop mobile web applications easily.Other than mobile web applications It’s focus is also on better HTML5 support and making ASP.NET MVC web application cloud ready.

By using new features of ASP.NET MVC 4 you can develop web applications that can work well across different desktop web browsers and mobile devices.

What are the main features of ASP.NET MVC 4 used by ASP.NET Web API?

  1. Routing changes: ASP.NET Web API uses same convention for config mapping that ASP.NET MVC provides.
  2. Model Binding & Validation: ASP.NET Web API uses same model binding functionality, but HTTP specific context related operations only.
  3. Filters: The ASP.NET Web API uses most of built-in filters from MVC.
  4. Unit Testing: Now Unit testing based on MVC, strongly unit testable.

What is the use of Display Modes in MVC?

View can be changed automatically based on browser (For mobile and desktop browser’s)

Display Modes is newly added feature in ASP.NET MVC 4. Views selected automatically by application depending on the browser.

Example: If a desktop browser requests login page of an application it will return Views\Account\Login.cshtml view & if a mobile browser requests home page it will return Views\Account\ view.

What is engine in ASP.NET MVC? What are different engines available

Engine is parser for your code. There are two type of engines avaible. You can choose any one.

  1. ASPX Engine
  2. Razor Engine

Difference between MVC and MVP

MVP Pattern:

  1. View is more loosely coupled to the model. The presenter is responsible for binding the model to the view.
  2. Easier to unit test because interaction with the view is through an interface
  3. Usually view to presenter map one to one. Complex views may have multi presenters.

MVC Pattern:
  1. Controller are based on behaviors and can be shared across views
  2. Can be responsible for determining which view to display

How to implement Windows authentication for MVC?

For Windows authentication you need to modify the web.config file and set the authentication mode to Windows.

<authentication mode="Windows"/>
<deny users="?"/>

Then in the controller or on the action, you can use the Authorize attribute which specifies which users have access to these controllers and actions. Below is the code snippet for that. Now only the users specified in the controller and action can access it.

[Authorize(Users= @"SystemName\Administrator")]
public class StartController : Controller
    [Authorize(Users = @"SystemName\Administrator")]
    public ActionResult Index()
        return View("MyView");

Hope this helps!!!

NuGet error on creating MVC4 Project in VS 2012

"Error: this template attempted to load component assembly 'NuGet.VisualStudio.Interop, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.".

If you encounter the above error. please do the following.

After it downloads, you will be prompted for administrative elevation, and then to restart Visual Studio.

Tested in: Visual Studio Ultimate 2012 (Version 11.0.60610.01 Update 3)

.Net Interview Questions and Answers for Experienced

What is the difference between a thread and a process?

What is the difference between an EXE and a DLL?

What is strong-typing versus weak-typing?

What is the difference between a.Equals(b) and a == b?

What is boxing?

Is string a value type or a reference type?

What is the Global Assembly Cache (GAC)? What problem does it solve?

What is an Interface and how is it different from a Class?

What is Reflection?

Conceptually, what is the difference between early-binding and late-binding?

When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?

What is an Asssembly Qualified Name? Is it a filename? How is it different?

How is a strongly-named assembly different from one that isn’t strongly-named?

What does this do? sn -t foo.dll

How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?

What is the difference between Finalize() and Dispose()? (external article)

What is the difference between in-proc and out-of-proc? What technology enables out-of-proc communication in .NET?

What is FullTrust? Do GAC’ed assemblies have FullTrust?

What is the difference between Debug.Write and Trace.Write? When should each be used?

What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?

What is the difference between: catch (Exception e) {throw e;} and catch (Exception e) {throw;} ?

What is the difference between typeof(foo) and myFoo.GetType()?

What is the purpose of XML Namespaces?

What is the difference between an XML "Fragment" and an XML "Document"? (XML Basics)

How would you validate XML using .NET?

What is a PostBack?

What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? Why is it either useful or evil?

What Session State providers are available in ASP.NET? What are the pros and cons of each?

What is the OO relationship between an ASPX page and its CS/VB code behind file?

How would one implement ASP.NET HTML output caching, caching outgoing versions of pages generated via all values of q= except where q=5 (as in http://localhost/page.aspx?q=5)?

What are HttpHandlers?

What are HttpModules?

What is needed to configure a new extension for use in ASP.NET? For example, what if I wanted my system to serve ASPX files with a *.jsp extension?

How do cookies work? What is an example of Cookie abuse?

What kind of data is passed via HTTP Headers?

How does IIS communicate at runtime with ASP.NET? Where is ASP.NET at runtime in the different versions of IIS (5 to 7)?

Whats the difference between an abstract class and interface? When would you want to use them?

What's the difference between a left join and an inner join?

What's the difference between viewstate and sessionstate?

What's the difference between overriding and overloading a method? Explain how both are done.

What's the difference between protected and internal? What about "protected internal"?

How do short-circuited operators work?

Explain what the StringBuilder class is and why you'd want to use it?

What's the difference between a static method and a non-static method?

What does the "volatile" keyword in C# mean?

Explain what happens when you pass a "ref" or "out" parameter into a method. What's the difference between those two keywords?

What's a weakreference? When would you want to use one?

What's the difference between a DataTable and a DataReader?

What's the difference between a value-type and a reference type?

What does the "readonly" keyword in C# mean?

Advantages of mvc over webforms

ASP.NET Web Forms and MVC are two web frameworks developed by Microsoft - they are both good choices. Neither of the web frameworks are to be replaced by the other nor are there plans to have them 'merged' into a single framework. Continued support and development are done in parallel by Microsoft and neither will be 'going away'.

Each of these web frameworks offers advantages/disadvantages - some of which need to be considered when developing a web application. A web application can be developed using either technology - it might make development for a particular application easier selecting one technology versus the other and vice versa.

The main advantages of MVC are:

  • Enables the full control over the rendered HTML.
  • Provides clean separation of concerns(SoC).
  • Enables Test Driven Development (TDD).
  • Easy integration with JavaScript frameworks.
  • Following the design of stateless nature of the web.
  • RESTful urls that enables SEO.
  • No ViewState and PostBack events


The main advantage of Web Form are:

  • It provides RAD development
  • Easy development model for developers those coming from winform development.

Similar Tags