Dissecting Razor, part 2: Gluing the pieces together

Last time, we saw that ASP.Net Web Pages are implemented in two independent assemblies. These assemblies are not directly connected to each-other.

Razor Side

System.Web.WebPages.Razor.dll contains the RazorBuildProvider class, which allows ASP.Net’s build system to compile Razor pages.  This class uses a WebRazorHostFactory to create WebPageRazorHosts used to process CSHTML (or VBHTML) files into CodeDOM trees.  It compiles the CodeDOM tree and returns the generated type(which will typically inherit System.Web.WebPages.WebPage) to the build system.

WebPageRazorHost is coupled to the WebPages framework; it handles the non-standard base types for special pages (StartPage and ApplicationStartPage).

RazorBuildProvider can be configured to use a different WebRazorHostFactory that creates custom WebPageRazorHosts.  (more on this later)

WebPages Side

The WebPages framework contains an internal WebPageHttpModule class which runs when an ASP.Net AppDomain is started.  It runs any _AppStart files, and hooks the request lifecycle to handle requests for CSHTML (or VBHTML) pages.

Requests for Razor pages are handled by System.Web.WebPages.WebPageHttpHandler.  This class passes the page’s virtual path to the build manager and gets a WebPage instance (It assumes that RazorBuildProvider will build the page and give a WebPage instance). 

The handler calls the page’s ExecutePageHierarchy method to serve the page to the client.  This method runs any _PageStart pages in the page’s parent directories, then executes the page.

The WebPageHttpHandler will also add a custom HTTP header, X-AspNetWebPages-Version: 1.0.  This can be disabled by setting WebPageHttpHandler.DisableWebPagesResponseHeader to false.

As mentioned, System.Web.WebPages.dll is not directly tied to the Razor language and engine.  One can create a custom build provider which compiles classes that inherit WebPage, then call WebPageHttpHandler.RegisterExtension to tell the WebPages framework to handle requests to the extension, without using the Razor parser.

The source code for this project is part of the same bundle.

Next time: MVC Razor views

30 comments:

Such blogs are great to read. Susy

Try to have a look at these advices if you want to know the best UK university. It was useful to read for me and my college friends

I recently ran over your site and have been reading along the blog you have made. I figured I would leave my first comment. I might want to thank you for the efforts you have made in writing this article. I trust a similar best work from you later on also. Truth is told your creative writing capacities have motivated me to begin my own blog now. Here you can check out my best essay writing service to having a wonderful support for your writing.

Hi there! Thanks for sharing this type of interesting information. If you are a student who is constantly assigned academic papers, make sure you have full access to our academic essays database and essays database online.

Schbase, thanks man for giving the detailed information of ASP.net .For the beginners its very tough to understand these languages as there is lot of complexity in these tools .When I was begin my development job in essay writing service firm I faced a lot of troubles but with the passage learnt all the things from seniors .

mr jatt Mp3 New Punjabi Song,Single Tracks Latest song download also Listen Latest Music Albums Online in High Quality at Mrpendus.in
mr jatt

Nowadays everybody can easily improve writing skills. There are nothing difficulties, simply need to concentrate on the mind. Think positive and write anything on anyway from your mind. Another solution is you need to search online for some new ideas or creativity things and also you need to read articles. I'm a freelancer and I must develop my writing skills because I writing avatar movie review essay and it helps begin to see your writing mistakes and develop your member and mind.

Legitimate creative assignment writing service has become very popular among students seeking Custom Creative Writing Services and creative research paper writing services.

I know that nowadays many people use help of professional resume service. It seems to me, great idea. One o these services is https://essaysworld.net/resume-writing-service. You can rely on professional writers from this service.

I think part two is too short. I need more details to finish my pre written essays for sale i hope to submit them next week.

Apply for freely modelling jobs, writers jobs, freelance makeup artists,freelance artists jobs, freelance stylist jobs, freelance singers jobs, freelance painters jobs. jobs for artist

Are you the one who find the SPSS Assignment complex? Here is the complete information related to the SPSS Assignment Help . Check it now.

If you are running short of time and have an instant need to complete your really tedious chemistry assignment, then please go ahead and get in touch with us. We, Help in Homework offer high quality and meticulously researched Chemistry Homework Help to students who are not able to complete their assignment on time as per the given specifications. Our experts are known personalities of their fields and have helped students consistently. They would without a doubt complete your assignment and help you score the coveted A grade, that too, at a nominal charge.

Get all the latest gossip, news, viral memes, YouTube videos at one place in hindi. Get all the details in Hindi. upcoming web series hindi

Nice and informative article. And the style that you write in good too. Also this post help me to realize what essay master I want to bee.

Looking for the best study guides online? We offer Test Bank For Essentials Of Psychiatric Mental Health Nursing Revised Reprint 2e 2nd Edition at the lowest prices. Download instantly and improve your grades today.

Looking for the best study guides online? We offer Test Bank For Exploring Management 4th Edition at the lowest prices. Download instantly and improve your grades today.

Scholaron offers the cheapest Online Homework Help with instant expert assistance. Get the best experts to assist you today!

Gain better scores in every assignment and exam with Solution Manual For Managerial Accounting 2. Be on the top of your class.

Do not waste countless hours on your college assignments anymore. Get Solution Manual For Prealgebra 1st Edition and work smart with better results.

Hard exams, assignments and homework are a now things of the past with Contemporary Labor Economics 11th Edition Solution Manual . Order and download now!

Gain better scores in every assignment and exam with Test Bank For International Business The Challenges Of Globalization 7 E 2 . Be on the top of your class.

Test banks and solution manuals are the best learning aids for any student. Try Solution Manual For Forensic Science From The Crime Scene To The Crime Lab 4th Edition with instant download and unlimited access.

This type of message always inspiring and I prefer to read quality content, So happy to find good place to many here in the post, the writing is just great, thanks for the post.
check here

Make the best use of your time by browsing about this awesome topic right away!

Hey great article.. find this excellent page, one of the most interesting info online.

Click on this article, an interesting read and a must know information for everyone.

Post a Comment