Dissecting Razor, part 4: Anatomy of a Razor Page

After looking at the various assemblies in the WebPages framework, we will drill into the inner workings of Razor pages.

Razor Side

An ordinary CSHTML page is transformed into a class which inherits the WebPage class.  The generator overrides the abstract Execute() method from the to render the page to the HTTP response stream.

Except for class-level directives and constructs (which will be discussed later), all ordinary content in a Razor page end up in the Execute method. 

There are three types of normal content: Literals, Code Blocks, and Code Nuggets.

Literals include any normal text. Razor compiles literal text into calls to the WriteLiteral method, with the text as a (correctly-escaped) string parameter.  Razor expects this method to write its parameter to the page.

Code Blocks include @{ ... } blocks, as well as control structures.  They’re Razor’s equivalent of <% ... %> blocks.  The contents of a code block are emitted as-is in the Execute method.  Code blocks must contain complete statements, or they’ll result in C# syntax errors.

VBHTML pages use @Code ... End Code blocks instead.

Code Nuggets are @-blocks.  They’re Razor’s equivalent of <%: ... %> blocks in an ASPX page.  Scott Guthrie describes how these blocks are tokenized.  The contents of a code nugget are passed to the Write method, which is expected to HTML-escape its parameter and print it.

WebPages Side

The WebPages framework’s  Write method (which comes from the WebPageBase class) takes a parameter of type Object, allowing one to put any expression in a code nugget.  It passes its parameter to HttpUtility.HtmlEncode, which will call ToString() and HTML-escape the output.  If the parameter is an IHtmlString, HtmlEncode will return its ToHtmlString() method without escaping.

The base class, method names, and default namespaces can be configured in the RazorEngineHost.  In addition, custom RazorEngineHosts can override the PostProcessGeneratedCode method to make arbitrary modifications to the generated code.

The WebRazorHostFactory in System.Web.WebPages.Razor.dll can also read default namespaces, a default base type, and a custom host from the <system.web.webPages.razor> section in Web.config:

    <host factoryType="MyProject.MyWebPageRazorHost" />
    <pages pageBaseType="MyProject.CustomWebPage">
            <add namespace="MyProject.SomeNamespace" />

Next Time: Looking at the generated page


These tips are nice to read. Bella

I know that after reading information from https://order-essay-online.net/blog/essay-rhetorical-devices you will learn more about essay rhetorical devices. I had such experience recently

McAfee Activate – Get robust protection by downloading and installing the McAfee antivirus. Go to McAfee Activate and enter the product key to activate your McAfee product #mcafee #activate mcafee.com/activate | mcafee.com/activate | mcafee.com/activate | mcafee.com/activate

Thank you so much for sharing such superb information's with us. Download the Microsoft Office setup on your Microsoft application provides a better way to access information, and consequently, users can have greater insight, and they can manage most of their essential work with more productivity and in less time. office.com/setup mcafee.com/activate|office.com/setup

Thanks for sharing this marvelous post. I m very pleased to read this article.

الرياض الى مصر نقل عفش من الرياض الى مصر
نقل عفش بالدمام نقل عفش بالدمام
نقل عفش بالاحساء نقل عفش بالاحساء
نقل عفش داخل مكة نقل عفش داخل مكة

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

There are many online environmental health research paper writing services and Environmental Health Writing Services to choose from for those stuck with their environmental health essay writing services and environmental health assignment writing services.

I have kept your website. It is illuminating and fulfilling for me. I regard the central information you offer on your site. A devotion of thankfulness is all together for posting it.
helo app download for pc

The Hp printer is the finest printer on the market with high quality home and office facilities for everyday use. You need to unbox them if you purchase a new HP

printer, then set it up with a PC or laptop. By visiting url: 123.hp.com/setup, the user can download and update applications and printer drivers.

Norton is the most used antivirus in the world and the foremost who has a lot of fame, after buying Norton Antivirus. You can create a Norton account by following the

instructions by visiting norton.com/setup official website. and easily install Norton with a product key or key code.

In other words, it can be defined as a software package containing different facilities, programmes and servers. The Microsoft Office suite is the productivity suite.

garmin express is a special application designed by Garmin to manage Garmin devices. This incredible app is used for map updates, device registration, software updates and syncing of fitness data with Garmin Connect. However, the services are not confined to these, but there are many more that you can do with the help of Garmin Express. However, that depends upon the status of Garmin Express, whether it is up-to-date or not because if it is not, then you won’t be able to enjoy all the aforementioned benefits.

Roku is the easiest way to link your Roku device with your tv and gives next level video streaming experience. roku.com/link has millions of users in the United States. After all, it’s very convenient in terms of you. You can watch more than five lacs of free and paid movies, videos, and tv shows. You only need to visit the official Roku link roku.com/link to get started with your Roku device. The Roku itself is a compact video streaming device that can merge all user’s favorite tv shows, videos, and movies together.

Webroot is among the ideal antivirus programs. It gives safety from malware and malware dangers. www.webroot.com/safe is a cybersecurity firm that demonstrates complete security for your personal information and banking information. Therefore, Webroot is the least expensive antivirus program. It includes numerous languages under the computer program. To begin with, this high caliber of cyber protection on your computer.

Webroot is among the ideal antivirus programs. It gives safety from malware and malware dangers. www.webroot.com/safe is a cybersecurity firm that demonstrates complete security for your personal information and banking information. Therefore, Webroot is the least expensive antivirus program. It includes numerous languages under the computer program. To begin with, this high caliber of cyber protection on your computer.

Canon wireless printer on your computer. Let’s suppose, you have just connected your network to the printer, you don’t have any recoverable media drive like DVD, CD ROM, or you don’t even have a flash drive to install your canon ij setup printer drivers, or perhaps printer installation through the media has failed multiple times, worry not. We will guide you today to install and set up your Canon printer wirelessly while performing a complete installation.

amazon.com/mytv is the official web link to activate amazon prime video subscription safely. Various media players are being launched nowadays. Media players support the best quality of videos. But still, they fail to provide it. So for the best video quality support, Activate Amazon my TV is being launched. Prime video is a popular platform. It gives you high-quality videos that many other media players fail to provide. Amazon mytvis a platform that shows the original quality of the video.

Plex represents two forms i.e. Paid and free. Users can enjoy the freedom, as well as paid service as the only difference in them, is of no. of channels and movies. Now the wait for the movies, serials, and a lot more tv shows is over as this can be done with the help of plex. You just have to create an account on the plex and download the application applicable to your device and enjoy the https://plexcotv.com. The steps of installation are explained below.

Norton manages to protect your passwords. It also provides cyber-security and it automatically updates itself. Norton warns us about unsafe and unknown websites. It provides safety while surfing online. It’s the most used antivirus in the United States. To install Norton on your Pc then read the full article provided below. Visit https://devnorto.com for more information regarding norton.

roku.com/link is a player that allows a stream of video content on various channels like ESPN, YouTube, HBO, etc. through a smart Tv that requires a WiFi internet connection for streaming. It is in the form of a box or a stick form. You can stream the channels whenever you want. The 9th generation is the latest generation of Roku. It also has its own channel for streaming. It is the most popular streaming device in the United states. The steps to set up as well as install Roku on your Tv is explained in this article.

You can book call girls in Guwahati or escorts in Guwahati for incall facility or outcall
Facility as and when required. To book Guwahati call girls you
can visit the following links
Call Girl in Guwahati
Guwahati Call Girl

office setup home student 2019 is an all-purpose application bundle that makes presentations, calculations, and reports simple. Microsoft is an American firm, succeeds in providing the vast software package of applications for the official workplace.

This blog is very informative and is very helpful for understanding web pages..


Ik vond dit een informatieve blog en ook erg nuttig en deskundig. Bellen google

Positieve webpagina-bron, waar heb je de informatie over dit bericht gevonden? Bedankt voor het delen. telefoon bellen Instagram

Zeer informatieve blog. bedankt voor het delen met ons.Bellen Outlook

Post a Comment