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

32 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.

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

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!

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

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.

Just to add a few words to the excellent article above, have you ever wondered where you can find the best test banks and solution manuals online? The answer to this question is just a click away. Checkout this Human Resource Management 15th Edition Solution Manual 2 to get an immediate A+.

Data is stored in variables. Variable names cannot contain whitespace or reserved characters and must start with an alphabetic letter. A variable's type, which describes the type of data it contains, might vary. Date variables hold date values, integer variables store number values (103), string variables store string values ("Welcome to W3Schools"), etc. The Dim keyword or the type (if you want to define the type) are used to declare variables, however ASP.NET often detects data types automatically. READ: Thresh Wild Rift Champion Build, Runes, & Item Guide here!

Adam,
https://games.lol/blog/roguelike-games-to-play-on-pc/

College exams are not hard anymore! Face even the toughest tests and assignments with Test Bank For Revel For Working In Groups Communication Principles And Strategies 7th Edition right away!

TestBank23 is the best place you can get Solution Manual For Calculus 6th Edition at the best distount and ace your grades.

Your blogs are really good and interesting. It is very great and informative Fairfax Traffic Lawyer. It compiles the CodeDOM tree and returns the generated type(which will typically inherit System.Web.WebPages.WebPage) to the build system. I got a lots of useful information in your blog. Keeps sharing more useful blogs..

Without specific information about "slaks blog," it's challenging to provide a precise definition. "Slaks blog" could refer to a personal blog named "Slaks" covering a variety of topics, or it might be a niche blog with a specific focus. For accurate details, additional context or information about the blog's content is needed.
Estate Lawyer Near Me
trucking accident lawyers






"In the second part of 'Dissecting Razor,' witness the art of precision as we guide you through the intricate process of gluing the razor's components together. Unveil the craftsmanship behind assembling each piece, ensuring a seamless and razor-sharp result. Dive into the world of meticulous construction and bring your razor to life with our step-by-step guide. Stay tuned for the ultimate shaving experience." reckless driving virginia first offense

Post a Comment