.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Migrate an ASP.NET MVC 2 project to MVC 3 Razor view

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
Hi all, I have an application which has been built in MVC 2.0. I need to upgrade it to MVC 3.0 and that too by using Razor CSHTML engine. All the information which I got on the net was for MVC 3.0 Webform engine but nothing much for migrating to Razor. I would be very grateful if somebody shows me the steps or sample walkthrough for the purpose of this migration. Any help would be greatly appreciated. Thanks and regards, Tanay.

View Complete Post

More Related Resource Links

Razor View Engine and Add Namespace in Web.Config Problem



I am working on a MVC project with Razor view engine and I have the following:


This only works if I have on the same view the following:

  @using SquishIt.Framework;

However, on my Web.Config I have the following:


      <!-- Namespaces -->
        <add namespace="System"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="Microsoft.Web.Mvc"/>
        <add namespace="SquishIt.Framework"/>


So if "SquishIt.Framework" namespace is added on Web.Config why do I need to have the @using on the view?

Does the Razor View Engine Support Generic Methods?

Trying out the Razor view engine and for some reason my generic helper methods are breaking. For example: public static class UrlHelperExtensions { public static string NonGenericHelper(this UrlHelper helper, Type controller) { return controller.Name; } public static string GenericHelper<TController>(this UrlHelper helper) { return typeof(TController).Name; } } Works as expected: @Url.NonGenericHelper(typeof(ProjectEuler.UI.Models.Home)) Breaks with the following exception: @Url.GenericHelper<ProjectEuler.UI.Models.Home>() "CS1502: The best overloaded method match for 'Microsoft.WebPages.WebPageUltimateBase.Write(Microsoft.WebPages.Helpers.HelperResult)' has some invalid arguments" The only workaround I could find is treating it as a "multi-token statement": @(Url.GenericHelper<ProjectEuler.UI.Models.Home>()) Not sure if this is the intended behavior or just a bug but it would be nice to be able to call a generic method as you would a non generic one.

how to migrate .net project from ie6 to ie8



I developed one project with compatible to ie6. now i want to convert that project to compatible of ie8 . what is the solution?

If any body know please let me know..

Start project from view => full view path appended to the URL => 404



If I start the project while in a view, it appends that view name (and path) to the URL, and I get a 404 error.


If I then switch to any non-view, like the controller and hit F5, it starts up with no additional URL and gets routed to the default controller.


 Is there a way to fix this? Is it an option (to not pass the view url on debug), or a routing cfg issue? I'm no MVC expert.

routes.MapRoute(	"Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } );

Thank you 

MVC3 Razor - Create a instance of a View


In my controller method, I'm trying to create an instance of a View (cshtml file) before I wrap it around an ActionResult and return it.

Since there is no "class" for Razor Views to speak off, how does one go about creating an instance of a Razor View?

MVC3 beta Razor View Base class/inheritance issues


There seem to be a few issues in the way Razor views are designed and the code generated

1. Descendants of WebViewPage are forced to override Execute() (since it is abstract) but that method is never called. Why?

2. The virtual method ConfigurePage is never called in descendants that override this method.

3. CreatePageFromVirtualPath is no longer virtual. This was the one method that gave us access to the Layout Page (Master Page) instance. Now we no longer have this access. Why was this done?

How can one get access to the instance of a Layout page?

Razor View Engine problem in Preview corrected in Beta?



On my projects I am using Razor View engine and I need to define custom Partial folders:

      // Define default view engine
      ViewEngines.Engines.Add(new CshtmlViewEngine());
      ViewEngines.Engines.Add(new WebFormViewEngine());

      // Define Razor view engine
      CshtmlViewEngine razor = (CshtmlViewEngine)ViewEngines.Engines[0];

      // Register partial views folders                
      razor.PartialViewLocationFormats = razor.PartialViewLocationFormats.Concat(new String[] { "~/Views/Partial/{0}.cshtml" }).ToArray();
      razor.AreaPartialViewLocationFormats = razor.AreaPartialViewLocationFormats.Concat(new String[] { "~/Areas/{1}/Views/Partial/{0}.cshtml" }).ToArray();

I had this because there was a problem in MVC 3 Preview. Was it corrected?

How should I register the Partial Views in MVC 3 Beta?

Thank You,


Displaying partial view/View from another project in MVC


Hi guys,

i wonder if you know which is the best way (concerning performance) to display a view from another project.

I have a cms from which i create the contents. I have my website and may in the future work for other websites. 

I have two options so far:

1) Generating the content from my cms and using it as an embedded resource in the website

2)Using http handler, i get the content from the url and response.write it on the part of the page

Please let me know if there are better options?

Thank you for your help.

2 bugs in Razor view engine


I found 2 bugs in Razor view-engine.

1. I can't write any inline-templates in _ViewStart, cause

WriteLitralTo is not defined in ViewStartPage class

2. Translator inserts unnecessary whitespace writes

For ex:



Func<int, HelperResult> intFormatter = @<text>- @item -</text>;


That code translates to:

public class _ViewStart_cshtml : System.Web.Mvc.ViewStartPage {


public override void Execute() {

Func<int, HelperResult> intFormatter =item => new

System.Web.WebPages.HelperResult(__razor_template_writer => {

 WriteLiteralTo(@__razor_template_writer, " ");

 WriteLiteralTo(@__razor_template_writer, "- ");

                WriteTo(@__razor_template_writer, item);

 WriteLiteralTo(@__razor_template_writer, " -");






CS0103: The name 'WriteLiteralTo' does not exist in the current context

WriteLiteralTo is defined in System.Web.WebPages.WebPageBase, but

StartPage does not inherited from it.


Why these unnecessary WriteLiteralTo calls (" ")? - there is no in my

code. And these unneces

Connect "Project Tasks" List's Calendar View to Outlook


I would like to connect our department's "Project Tasks"-type list to an Outlook calendar (the same way I can do with a "Calendar"-type list).  

In Sharepoint, I have a nice "Calendar View" (this is a Sharepoint View/Report using the "Calendar" format) of the "Project Tasks"-type List items showing which items were worked on in the past or are to be worked on in the future.  I would like to Connect this view to Outlook, but it appears this "Project Tasks"-type list does not have the "Connect to Outlook" option in the ACTIONS menu.  

I have confirmed that the "Connect to Outlook" option is activated in our "Enable Client Integration" settings per thread ((http://www.eggheadcafe.com/community/aspnet/69/10091824/cannot-see-connect-to-outlook-in-the-actions.aspx).  In fact, if I create a strict "Calendar"-type list (instead of a "Project Tasks"-type list or "Issue Tracking"-type list), I do get the "Connect to Outlook" option in the ACTIONS menu.  I'd li

ASPX View Engine Vs Razor View Engine in ASP.NET MVC

View Engine in ASP.NET MVC is used to translate our views to HTML and then render to response.

Truly Understanding View State

This article provides a detailed understanding of the ViewState.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.

Model View Controller (MVC) for ASP.NET

Model View Controller (MVC) architectures, immediately wonder how the MVC pattern can be applied in an ASP.NET world. This article will demonstrate how the MVC pattern can be applied to an ASP.NET web application and still maintain the basic Microsoft supplied architecture.

Project Example: ASP.NET MVC + SubSonic Architecture

use of SubSonic to provide the DAL in association with some ASP.NET MVC sites and was waylaid in my original intent to throw up a post summarizing the architecture we're using for the effort. Well I've finally gotten around to it. Recall that in his fake it till you need it post, Dave provided a window on our architecture that I'll build upon here

jQuery grid view plugin

jqGridView is new, client-rich, XML-based, ajax grid plugin for jQuery library. jqGridView provides professional solution for representing and editing tabular data on the web. Carefully designed, with powerful script API, this editable DHTML grid is easy configurable with XML, and shows convincing results working with large amounts of data. jqGridView allows easy implementation of nice looking(managed through css). jqGridView is not platform-depending plug-in, it can be used with different web -programming platforms like: ASP .NET/ASP, PHP, JAVA, CGI scripts etc. jqGridView has hight bowser compatibility.

jQuery grid view plugin

jqGridView is new, client-rich, XML-based, ajax grid plugin for jQuery library. jqGridView provides professional solution for representing and editing tabular data on the web. Carefully designed, with powerful script API, this editable DHTML grid is easy configurable with XML, and shows convincing results working with large amounts of data. jqGridView allows easy implementation of nice looking(managed through css
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend