JetBrains Rider 2021.2 Help

Predefined File Templates for Razor (C#)

This topic lists all predefined file templates for Razor (C#) in JetBrains Rider 2021.2. For more information about file templates, see Create files from templates

Template

Details

Razor MVC Partial View

Razor MVC Partial View

Scope Razor (C#) projects, Razor (C#) Views folder

Body

@model $model$ $END$

Parameters

  • model- Guess type expected at this point

  • END- The caret position after the template is applied.

Razor MVC View

Razor MVC View

Scope Razor (C#) projects, Razor (C#) Views folder

Body

@model $model$ @{ Layout = null; } <!DOCTYPE html> <html> <head> <title>$title$</title> </head> <body> <div> $END$ </div> </body> </html>

Parameters

  • model- Guess type expected at this point

  • title- no macro

  • END- The caret position after the template is applied.

Razor MVC View with Layout

Razor MVC View with Layout

Scope Razor (C#) projects, Razor (C#) Views folder

Body

@model $model$ @{ ViewBag.Title = "$title$"; Layout = "$_Layout$"; } <h2>$title$</h2> $END$

Parameters

  • model- Guess type expected at this point

  • title- no macro

  • _Layout- Show smart code completion list at the point where the variable is evaluated

  • END- The caret position after the template is applied.

Controller

Scope Razor ASP.NET Framework projects

Body

$HEADER$using System.Web.Mvc; namespace $NAMESPACE$ { public class $CLASS$: Controller { // GET public ActionResult Index() { $END$return View(); } } }

Parameters

  • HEADER- Inserts the file header specified in the JetBrains Rider settings.

  • CLASS- Evaluates current file name without extension with all non-alphanumeric replaced with underscores

  • NAMESPACE- Gets default namespace for the current file

  • END- The caret position after the template is applied.

Component

Scope Blazor (C#) Projects

Body

<h3>$COMPONENTNAME$</h3> @code { $END$ }

Parameters

  • COMPONENTNAME- Evaluates current file name without extension with all non-alphanumeric replaced with underscores

  • END- The caret position after the template is applied.

Page

Scope Blazor (C#) Projects

Body

@page "/$PAGENAME$" <h3>$PAGENAME$</h3> @code { $END$ }

Parameters

  • PAGENAME- Evaluates current file name without extension with all non-alphanumeric replaced with underscores

  • END- The caret position after the template is applied.

Last modified: 21 October 2021