Dissecting Razor, part 3: Razor and MVC

Last time, we saw how standalone Razor pages are served.

MVC3 maintains the strict separation between the WebPages framework and the Razor engine.1

Razor Side

Like the WebPages framework, MVC3 interacts with Razor indirectly, by relying on RazorBuildProvider from System.Web.WebPages.Razor.dll.   However, MVC3 requires that Razor views inherit its own base class, System.Web.Mvc.WebViewPage.

MVC3 adds a new @model directive, which can be used instead of @inherits to specify a strongly-typed model.  This syntax is implemented by customized RazorCodeParsers and RazorCodeLanguages in the System.Web.MVC.Razor namespaces.  These classes are invoked by MvcRazorEngineHosts from a custom RazorHostFactory registered in Views/Web.Config:

    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />

MVC Side

On the MVC side, MVC3 includes a new RazorViewEngine which creates RazorView instances.  RazorView inherits the existing BuildManagerCompiledView class, which passes the view’s virtual path to the build manager.  RazorView will take the WebViewPage from the build manager, find any matching start pages, and execute the view.

As with the WebPages framework, one can substitute other templating engines.  One can register a build provider which compiles classes that inherit WebViewPage, then add a RazorViewEngine to ViewEngines.Engines with additional extensions in its FileExtensions property.

Next time: Inside Razor Pages


Hey thanks for the explanation. I was trying to figure out what configuration is needed to get the @model keyword supported, and I suspected it was only the host configuration. Now I see the first confirmation in your post. Not many people have explained this is into so much depth, much appreciated!

Hi.I have this code in my controller action

public class ShipperController : Controller
FxDataClassesDataContext dcfx = new FxDataClassesDataContext();

public ActionResult GridActiveQuotes(string sidx, string sord, int page, int rows)

int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
int totalRecords = dcfx.FxVwQuotes.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

var opp = (sord == "asc") ?
.Skip(pageIndex * pageSize)
.Skip(pageIndex * pageSize)

var jsonData = new
total = totalPages, // Work item
page = page,
records = totalRecords, // Work item
rows = (
from Quotes in dcfx.FxVwQuotes
select new
id = Quotes.Quote_ID,
cell = new string[] {


return Json(jsonData, JsonRequestBehavior.AllowGet);

How do i display this array in a listview?PLEASE HELP

Such blogs are great to read. Sally

This article helped me understand it all.
call girls from London

It will be useful for college students to take a look at these advices. Here you can get some persuasive essay topics

This is actually a very informative article – not like most of what I see online. Thanks for the free share and looking forward to reading your updates! simply wow
canon printer support | sony printer support | samsung printer support | brother printer support

Great post feeling amazing after read it thanks for useful ideas please keep sharing.
hp printer support

Get 24/7 expert customer services for all your QuickBooks software issues. Dial the QuickBooks support toll-free number to get instant assistance.

quickbooks support

Mcafee antivirus is very easy to install, download and redeem product key. Use of Mcafee is also simple and you just need to install McAfee and rest application will do.

Mcafee Product Activation online using the internet is easy. Go to the official site and purchase it. Save it, run it and pass through some easy instruction and agree with all the policies.

mcafee.com/activate | mcafee.com/activate | mcafee.com/activate

Active Mcafee online product key online. A product key is of 25-characters and it is sent to you by the confirmation mail. But if you want to install it using a CD drive, insert CD and run it. It will start the same process of installation as given above.

When you are buying Mcafee antivirus software for your business or setting home for personal use. The Application suite has something for all users either it is personal use, small business use or big business use. And each user feels the product satisfaction and feel that you get the best as per you spent on the Software.

mcafee.com/activate | mcafee.com/activate | mcafee.com/activate | mcafee.com/activate

QuickBooks customer service experts and certified ProAdvisors will give you the best solutions for your business. Our QuickBooks support line experts have years of expertise in solving technical issues with QuickBooks, providing the best QuickBooks help and technical solutions to business owners, maintaining and optimizing QuickBooks.

Take a look at short answer question examples at top papes to be ready for passing tests

Keep all the maps and software in your Garmin device updated with Garmin Express Download. We can transfer all needful essentials to other Garmin device. Garmin software update keeps checking the latest available updates for maps and software. Get Garmin life time map update or call +1-888-309-0939 for instant help from Garmin GPS experts.

I never used all the features of MyGarmin Express. But still I can say that this is the best app I have ever used. Garmin Nuvi comes with some refined features. Check out Garmin Nuvi or call +1-888-309-0939 for instant help from Garmin GPS experts.

Professional Human Resource Writing Services is very popular for students in search of human resource case study writing services and human resource research paper services.

A for each loop is a common tool when working with an array or collection. The for each loop enables you to do a job on each item in a collection, which is a set of related objects. A collection is traversed by the for each loop until it is done. The Request.ServerVariables collection for ASP.NET is demonstrated in the example below. A general-purpose loop is the while loop. The while keyword is used to start a while loop, which is then followed by parentheses where you indicate how long the loop lasts and a repeat block. While loops generally increase or decrease a counting variable. The += operator in the example below increments the variable I by 1 each time the loop executes. Learn How to Play FR Legends on PC | Games.lol now!

See this Tales of Grimm Tier List guide also.

Post a Comment