Please navigate to the bottom of the page for Table of Contents

Friday, January 11, 2013

Asp.Net MVC interview questions

Asp.Net web UI has come a long way in the last 10 years. Starting for classic ASP world, we are now seeing the evolution of world class product in the form of Asp.Net MVC. Web Forms still work and are great for many specific applications. But MVC is the correct way to go for most internet applications.
In this and future posts, we will go over a few ASP.NET MVC interview questions. Let’s tackle Razor engine in this post.

Question: What is Asp.Net MVC Razor?

Razor is the newest view engine released by Microsoft. It’s key features include optimized Html generation, easy to learn, compact, expressive and enabling a fluid coding workflow. The Razor syntax is a template markup syntax that enables you to use an HTML construction workflow. Instead of using the ASP.NET .ASPX markup syntax with <%= %> symbols to indicate code blocks, Razor syntax starts code blocks with a @ character and does not require explicit closing of the code-block.

Question: How can you create a link to a JavaScript file in a view?
With MVC 4 release, the Razor engine has been updated to better serve files. Instead of having to use path mapping methods @Url.Content to render the content of the file, you can now render using the tilde ( ~ ) character as shown below:
<script src="~/Scripts/ref.js"></script>

Question: Display some content only if a certain property in the backing model is not null.
Many times, you have the situation where you need to change the CSS property for a certain block of text only if the backing model has that info. This relatively common feature can now be simply rendered by direct html binding as shown below:

<div class="@Model.HighlightImClass">@Model.UserIm</div>

Question: How can you set the checked state of input boxes based on backing model?
This is again similar in nature to the question above. You can directly bind boolean properties of the model to Html controls.

<input checked="@Model.IsFreeShipping" type="checkbox" />

Question: How can you use Razor to serve bundled CSS or JavaScript files?
In a nutshell? Very cleanly in an intuitive way. MVC 4 has a brand new syntax to serve bundled content as shown:

@Styles.Render("~/Content/cart/css", "~/Content/order/css")

There are a lot of good resources on the web to learn more about  MVC, Razor and Asp.Net in general. In the next post, we will look at some more complex interview questions on Views of MVC.


  1. Good. Please add more.

  2. Great, useful.

    I found another great article describing new features of ASP.NET MVC 4 in form of interview questions.


  3. Good one.
    For Top 10 ASP.NET MVC Interview Questions, please follow:

  4. Nikhil Sir Please Add Other features like WCF,WPF,SHAREPOINT ETC. //////////////////////////////////////]

    About MVC so much is left behind Please Add with this Page ++++++++++++++++++++++++++)


  5. The blog or and best that is extremely useful to keep I can share the ideas
    of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
    tanki online | 2048 game|

  6. This comment has been removed by the author.

  7. This comment has been removed by the author.

  8. Very useful,but very less in number.Expecting more questions....

    C# Tutorials

  9. Hiya,

    I love all the posts, I really enjoyed.
    I would like more information about this, because it is very nice., Thanks for sharing.

    I was wondering what's a good library or some code to find the similarities between one image and another image/images. I have some software I'm writing where the user has a set of images and he/she wants to compare one image to the rest and then output the similarities into an image file
    to visually see the differences. I've used code before to do very simple compares but they're not detailed enough and I have no clue how to output the similarities or differences into and image file. Does anyone have any ideas?

    I am so grateful for your blog. Really looking forward to read more.

    Kind Regards,
    Irene Hynes

  10. It’s really Nice and Meaningful. It’s really cool Blog. You have really helped lots of people who visit Blog and provide them Useful Information. Thanks for Sharing.Oracle Applications Training in Bangalore

  11. Some time all you have to do is arrange some Good quality office chairs from top brands to make your home office look really awesome and fantastic. Adding a good office vibe is really important trust me.

  12. Here in this article we ;re sharing with you the step by step guide on how to install the printer that hp printer printing blank pages. The steps would be easy to follow.

  13. Really infomational and educative article thanks publisher for sharing this wonderful info i have shared this article on my blog tecktak flippzilla
    and whatsaup, and Best smart tv

  14. We also provide CRM Software in Australia and CRM software in gurgaon. If you are interested, then please contact us for detailed information.

  15. really informative and educative article thanks publisher for sharing this wonderful information with us i have bookmakred this blog for future post
    gossip mouth