Thursday, November 24, 2011

MVC Interview Questions on razor views

What are the 2 popular mvc view engines?
1. Razor
2. .aspx

What symbol would you use to denote, the start of a code block in razor views?

What symbol would you use to denote, the start of a code block in aspx views?
<%= %>

In razor syntax, what is the escape sequence character for @ symbol?
The escape sequence character for @ symbol, is another @ symbol

When using razor views, do you have to take any special steps to proctect your mvc application from cross site scripting (XSS) attacks?
No, by default content emitted using a @ block is automatically HTML encoded to protect from cross site scripting (XSS) attacks.

When using aspx view engine, to have a consistent look and feel, across all pages of the application, we can make use of master pages. What is master pages equivalent, when using razor views?
To have a consistent look and feel when using razor views, we can make use of layout pages. Layout pages, reside in the shared folder, and are named as _Layout.cshtml

What are sections?
Layout pages, can define sections, which can then be overriden by specific views making use of the layout. Defining and overriding sections is optional.

What are the file extensions for razor views?
1. .cshtml - If the programming lanugaue is C#
2. .vbhtml - If the programming lanugaue is VB

How do you specify comments using razor syntax?
Razor syntax makes use of @* to indicate the begining of a comment and *@ to indicate the end. An example is shown below.
@* This is a Comment *@


  1. what is the difference between razor view engine and aspx view engine

  2. what are the advantages of mvc webapplication over normal aspx webapplications?

    1. MVC web application separates concerns which helps to development & management of large complex applications by larger team where as normal aspx app is file driven which means it is tedious and hard to manage complex applications.

  3. Why MVC instead of ASP.NET? What are the basic examples of using MVC instead of ASP.NET?

    1. MVC is a framework and can be used in wide variety of programming languages. It allows to keep business logic (Model) & front end UI (View) while the user actions are handled in the controller to make determination on which Model to be called and which UI need to be rendered(view).

  4. can we create Windows application using MVC?

    1. This is a web framork and thus Windows applications are not possible using MVC


Disclaimer - Terms of use - Contact Us