<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://logicwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Razor</id>
		<title>Razor - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://logicwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Razor"/>
		<link rel="alternate" type="text/html" href="https://logicwiki.co.uk/index.php?title=Razor&amp;action=history"/>
		<updated>2026-05-01T09:27:37Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>https://logicwiki.co.uk/index.php?title=Razor&amp;diff=27&amp;oldid=prev</id>
		<title>Dt1nh6: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://logicwiki.co.uk/index.php?title=Razor&amp;diff=27&amp;oldid=prev"/>
				<updated>2016-05-09T13:27:16Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 13:27, 9 May 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Dt1nh6</name></author>	</entry>

	<entry>
		<id>https://logicwiki.co.uk/index.php?title=Razor&amp;diff=26&amp;oldid=prev</id>
		<title>85.199.239.140: Created page with &quot;Category:MVC Category:ASP.NET Category:CSharp Category:TODO  Razor is a template syntax that allows you to combine code and content in a fluid and expressive m...&quot;</title>
		<link rel="alternate" type="text/html" href="https://logicwiki.co.uk/index.php?title=Razor&amp;diff=26&amp;oldid=prev"/>
				<updated>2014-08-15T12:57:06Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php?title=Category:MVC&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:MVC (page does not exist)&quot;&gt;Category:MVC&lt;/a&gt; &lt;a href=&quot;/index.php?title=Category:ASP.NET&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:ASP.NET (page does not exist)&quot;&gt;Category:ASP.NET&lt;/a&gt; &lt;a href=&quot;/index.php?title=Category:CSharp&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:CSharp (page does not exist)&quot;&gt;Category:CSharp&lt;/a&gt; &lt;a href=&quot;/index.php?title=Category:TODO&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:TODO (page does not exist)&quot;&gt;Category:TODO&lt;/a&gt;  Razor is a template syntax that allows you to combine code and content in a fluid and expressive m...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:MVC]]&lt;br /&gt;
[[Category:ASP.NET]]&lt;br /&gt;
[[Category:CSharp]]&lt;br /&gt;
[[Category:TODO]]&lt;br /&gt;
&lt;br /&gt;
Razor is a template syntax that allows you to combine code and content in a fluid and expressive manner. Though it introduces a few symbols and keywords, Razor is not a new language. Instead, Razor lets you write code using languages you probably already know, such as C# or Visual Basic .NET. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div&amp;gt;This page rendered at @DateTime.Now&amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 @if(User.IsAuthenticated) &lt;br /&gt;
 {    &lt;br /&gt;
   &amp;lt;span&amp;gt;Hello, @User.Username!&amp;lt;/span&amp;gt; &lt;br /&gt;
 } &lt;br /&gt;
 else &lt;br /&gt;
 {&lt;br /&gt;
   &amp;lt;span&amp;gt;Please @Html.ActionLink(&amp;quot;log in&amp;quot;)&amp;lt;/span&amp;gt; &lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Differentiating Code and Markup ==&lt;br /&gt;
Razor provides two ways to differentiate code from markup: code nuggets and code blocks.&lt;br /&gt;
=== Code Nuggets ===&lt;br /&gt;
Code nuggets are simple expressions that are evaluated and rendered inline. They can be mixed with text and look like this: &lt;br /&gt;
&lt;br /&gt;
 Not Logged In: @Html.ActionLink(&amp;quot;Login&amp;quot;, &amp;quot;Login&amp;quot;) &lt;br /&gt;
&lt;br /&gt;
The expression begins immediately after the @ symbol, and Razor is smart enough to know that the closing parenthesis indicates the end of this particular statement. The previous example will render this output: &lt;br /&gt;
 Not Logged In: &amp;lt;a href=&amp;quot;/Login&amp;quot;&amp;gt;Login&amp;lt;/a&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== Explicit code nuggets ==== &lt;br /&gt;
The explicit code nugget syntax (@( )) allows you to wrap a code statement, unambiguously marking the beginning and end of the statement.&lt;br /&gt;
&lt;br /&gt;
=== Code Blocks ===&lt;br /&gt;
A code block is a section of the view that contains strictly code rather than a combi- nation of markup and code. Razor defines a code block as any section of a Razor template wrapped in @{ } characters. The @{ characters mark the beginning of the block, followed by any number of lines of code. The } character closes the code block. Keep in mind that the code within a code block is not like code in a code nugget. It is fully-formed code that must follow the rules of the current language; for example, each line of code written in C# must include a semicolon (;) at the end, just as if it lived within a class in a .cs file. Here is an example of a typical code block: &lt;br /&gt;
&lt;br /&gt;
 @{ &lt;br /&gt;
    LayoutPage = &amp;quot;~/Views/Shared/_Layout.cshtml&amp;quot;; &lt;br /&gt;
    View.Title = &amp;quot;Product Details for &amp;quot; + Model.ProductName; &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== The @: character sequence ==&lt;br /&gt;
The @: character sequence The @: character sequence indicates a transition, telling Razor to assume that the con- tent that follows the sequence is content, not code&lt;br /&gt;
&lt;br /&gt;
 @if(User.IsAuthenticated) &lt;br /&gt;
 {    &lt;br /&gt;
    @:Hello, @User.Name! &lt;br /&gt;
 } &lt;br /&gt;
 else &lt;br /&gt;
 {    &lt;br /&gt;
   @:Please login &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;text&amp;gt; block == &lt;br /&gt;
The &amp;lt;text&amp;gt; block is an alternative to the @: character sequence that allows you to denote that an entire portion of a template is content.  &lt;br /&gt;
&lt;br /&gt;
 @if(!User.IsAuthenticated) &lt;br /&gt;
 {    &lt;br /&gt;
   &amp;lt;text&amp;gt;    &lt;br /&gt;
      Guests are not allowed to view this content.    &lt;br /&gt;
      Please @Html.ActionLink(&amp;quot;login&amp;quot;, &amp;quot;Login&amp;quot;) to view. &lt;br /&gt;
   &amp;lt;/text&amp;gt; &lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
 @* *@&lt;br /&gt;
&lt;br /&gt;
== Organizing Razor Templates ==&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
A layout template typically includes the main markup (scripts, CSS stylesheets, and structural HTML elements, such as navigation and content containers), specifying lo- cations within the markup in which pages can define content. Each page in the site refers to this layout, including only the content within the locations the layout has indicated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Take a look at a typical Razor layout file (_Layout.cshtml): &lt;br /&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
 &amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
        &amp;lt;meta charset=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;@View.Title&amp;lt;/title&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;header&amp;quot;&amp;gt;&lt;br /&gt;
            @RenderSection(&amp;quot;Header&amp;quot;)&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
        @RenderBody()&lt;br /&gt;
        &amp;lt;div class=&amp;quot;footer&amp;quot;&amp;gt;&lt;br /&gt;
            @RenderSection(&amp;quot;Footer&amp;quot;)&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Once a Razor layout is defined, pages reference the layout and supply content for the sections defined within the layout. The following is a basic content page that refers to the previously defined _Layout.cshtml file: &lt;br /&gt;
 @{ Layout = &amp;quot;~/_Layout.cshtml&amp;quot;; }&lt;br /&gt;
 @section Header {    &lt;br /&gt;
    &amp;lt;h1&amp;gt;My Blog&amp;lt;h1&amp;gt; &lt;br /&gt;
 }&lt;br /&gt;
 @section Footer {&lt;br /&gt;
    Copyright 2011 &lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;div class=&amp;quot;main&amp;quot;&amp;gt;   &lt;br /&gt;
    This is the main content.&lt;br /&gt;
 &amp;lt;/div&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Sections ===&lt;br /&gt;
Syntax : &lt;br /&gt;
 @section [Section Name] &lt;br /&gt;
 {&lt;br /&gt;
    [ Razor content, code, and markup ] &lt;br /&gt;
 } &lt;br /&gt;
==== IsSectionDefined ====&lt;br /&gt;
Determines whether a section of a given name is defined in the content view. &lt;br /&gt;
 @RenderBody()&lt;br /&gt;
    @if(IsSectionDefined(&amp;quot;Footer&amp;quot;))&lt;br /&gt;
    {&lt;br /&gt;
        &amp;lt;div class=&amp;quot;footer&amp;quot;&amp;gt;&lt;br /&gt;
            @RenderSection(&amp;quot;Footer&amp;quot;, required: false)&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== Nested Layouts  ===&lt;br /&gt;
Layouts can also be “nested.” A nested layout is any layout that refers to another, outer layout. &lt;br /&gt;
&lt;br /&gt;
=== Partial Views  ===&lt;br /&gt;
  RenderPage(&amp;quot;Posts/_Post.cshtml&amp;quot;, new { Post = post }) &lt;br /&gt;
&lt;br /&gt;
=== Razor Helpers ===&lt;/div&gt;</summary>
		<author><name>85.199.239.140</name></author>	</entry>

	</feed>