# ASP.NET Razor

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/ASP.NET_Razor
> Markdown URL: https://mediated.wiki/source/ASP.NET_Razor.md
> Source: https://en.wikipedia.org/wiki/ASP.NET_Razor
> Source revision: 1357265737
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Programming syntax for ASP.NET

Razor Original author Microsoft Developer .NET Foundation Release June 2010; 16 years ago (2010-06) Stable release 3.3.0 / October 23, 2023; 2 years ago (2023-10-23)[1] Preview release 4.0.0-rc1 / November 18, 2015; 10 years ago (2015-11-18) Written in C#, VB.NET, HTML Operating system Microsoft Windows[2] Type Web application framework License Apache License 2.0[3] Website www.asp.net/web-pages Repository github.com/aspnet/Razor github.com/aspnet/AspNetWebStack github.com/dotnet/aspnetcore

Razor file formats Filename extension .razor, .cshtml, .vbhtml Internet media type text/html Developed by Microsoft

**Razor** is an [ASP.NET](/source/ASP.NET) programming syntax used to create [dynamic web pages](/source/Dynamic_web_page) with the [C#](/source/C_Sharp_(programming_language)) or [VB.NET](/source/Visual_Basic_.NET) programming languages. Razor was introduced in June 2010[4] and was released for Microsoft [Visual Studio](/source/Visual_Studio) 2010 in January 2011.[5] Razor is a simple-syntax view engine and was released as part of [MVC](/source/ASP.NET_MVC) 3 and the [WebMatrix](/source/WebMatrix) tool set.[5]

Razor became a component of AspNetWebStack and then became a part of [ASP.NET Core](/source/ASP.NET_Core).[6]

## Design

The Razor syntax is a template markup syntax, based on the C# programming language, that enables the programmer to use an HTML construction workflow.[*[clarification needed](https://en.wikipedia.org/wiki/Wikipedia:Please_clarify)*] Instead of using the ASP.NET Web Forms (.aspx) markup syntax with <%= %> symbols to indicate code blocks, Razor syntax starts code blocks with an @ character and does not require explicit closing of the code-block.

The idea behind Razor is to provide an optimized syntax for HTML generation using a code-focused templating approach, with minimal transition between HTML and code.[7] The design reduces the number of characters and keystrokes, and enables a more fluid coding workflow by not requiring explicitly denoted server blocks within the HTML code.[4] Other advantages that have been noted:[8]

- Supports [IntelliSense](/source/IntelliSense) – statement completion support

- Supports "layouts" – an alternative to the "master page" concept in classic [Web Forms](/source/ASP.NET_Web_Forms) (.aspx)

- [Unit testable](/source/Unit_testing)

## See also

- [Free and open-source software portal](https://en.wikipedia.org/wiki/Portal:Free_and_open-source_software)

- [Blazor](/source/Blazor)

## References

1. **[^](#cite_ref-1)** ["Microsoft ASP.NET Razor"](https://www.nuget.org/packages/Microsoft.AspNet.Razor/). *[NuGet](/source/NuGet)*. [Archived](https://web.archive.org/web/20220405102339/https://www.nuget.org/packages/Microsoft.AspNet.Razor/) from the original on 2022-04-05. Retrieved 2015-12-03.

1. **[^](#cite_ref-2)** ["Introduction to Razor Pages in ASP.NET Core"](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-6.0&tabs=visual-studio). *learn.microsoft.com*. 27 September 2024. [Archived](https://web.archive.org/web/20221030191706/https://learn.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-6.0&tabs=visual-studio) from the original on 30 October 2022. Retrieved 30 October 2022.

1. **[^](#cite_ref-3)** ["Razor/LICENSE.txt at master · aspnet/Razor · GitHub"](https://github.com/aspnet/Razor/blob/master/LICENSE.txt). *GitHub*. 12 October 2022. [Archived](https://web.archive.org/web/20220405102339/https://github.com/aspnet/Razor/blob/master/LICENSE.txt) from the original on 5 April 2022. Retrieved 24 June 2019.

1. ^ [***a***](#cite_ref-IntroducingRazor_4-0) [***b***](#cite_ref-IntroducingRazor_4-1) ["ScottGu's Blog - Introducing "Razor" – a new view engine for ASP.NET"](https://web.archive.org/web/20101110065355/http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx). *asp.net*. 3 July 2010. Archived from [the original](http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx) on 10 November 2010. Retrieved 8 July 2011.

1. ^ [***a***](#cite_ref-RazorsyntaxSupport_5-0) [***b***](#cite_ref-RazorsyntaxSupport_5-1) ["MSDN Blogs"](https://web.archive.org/web/20120702131534/http://blogs.msdn.com/b/webdevtools/archive/2011/01/12/how-to-get-razor-syntax-support-in-visual-studio-2010.aspx). *msdn.com*. Microsoft. Archived from [the original](http://blogs.msdn.com/b/webdevtools/archive/2011/01/12/how-to-get-razor-syntax-support-in-visual-studio-2010.aspx) on 2012-07-02. Retrieved 2011-07-08.

1. **[^](#cite_ref-6)** Chadwick, Jess (9 September 2011). [*Programming Razor: Tools for Templates in ASP.NET MVC or WebMatrix*](https://books.google.com/books?id=z3QlDSjr0jYC&q=ASP.NET+Razor). O'Reilly Media, Inc. [ISBN](/source/ISBN_(identifier)) [978-1-4493-1716-4](https://en.wikipedia.org/wiki/Special:BookSources/978-1-4493-1716-4).

1. **[^](#cite_ref-MVC3rve_7-0)** Jon Galloway (19 February 2020). ["MVC 3 - Razor View Engine"](http://www.asp.net/mvc/videos/mvc-3/mvc-3-razor-view-engine). *The Official Microsoft ASP.NET Site*. [Archived](https://web.archive.org/web/20160919204009/http://www.asp.net/mvc/videos/mvc-3/mvc-3-razor-view-engine) from the original on 19 September 2016. Retrieved 31 January 2013.

1. **[^](#cite_ref-pro1_8-0)** ["ASP.NET MVC View Engine Comparison"](https://stackoverflow.com/questions/1451319/asp-net-mvc-view-engine-comparison). *stackoverflow.com*. [Archived](https://web.archive.org/web/20220424123647/https://stackoverflow.com/questions/1451319/asp-net-mvc-view-engine-comparison) from the original on 2022-04-24. Retrieved 2016-07-25.

## External links

Wikibooks has a book on the topic of: ***[.NET Development Foundation](https://en.wikibooks.org/wiki/.NET_Development_Foundation)***

- [Introduction to Razor Pages in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/razor-pages/) at [Microsoft Docs](/source/Microsoft_Docs) - [ASP.NET Web Pages](https://docs.microsoft.com/en-us/aspnet/web-pages/) at [Microsoft Docs](/source/Microsoft_Docs)

- [Overview of ASP.NET Core MVC](https://docs.microsoft.com/en-us/aspnet/core/mvc/overview) at [Microsoft Docs](/source/Microsoft_Docs) - [ASP.NET MVC](https://docs.microsoft.com/en-us/aspnet/mvc/) at [Microsoft Docs](/source/Microsoft_Docs)

- [Razor](https://github.com/aspnet/Razor) on [GitHub](/source/GitHub) (archived). Current development is held at [aspnetcore](https://github.com/dotnet/aspnetcore) on [GitHub](/source/GitHub)

v t e .NET .NET strategy Libraries and frameworks Implementations .NET (Core) .NET Framework Version history .NET Compact Framework .NET Micro Framework DotGNU Mono XNA Framework Architecture Common Language Runtime (CLR) COM Interop Framework Class Library (FCL) Components ADO.NET Entity Framework ASP.NET Web Forms AJAX Core Dynamic Data MVC Razor Avalonia ClickOnce Dynamic Language Runtime Extensible Application Markup Language (XAML) Language Integrated Query (LINQ) Managed Extensibility Framework Microsoft Silverlight Microsoft XNA Parallel Extensions Windows Communication Foundation (WCF) WCF Data Services Windows Forms (WinForms) Windows Identity Foundation (WIF) Windows Presentation Foundation (WPF) Windows Workflow Foundation (WF) .NET Remoting Tools Decompilers .NET Reflector dotPeek Obfuscators Dotfuscator SmartAssembly CLR Profiler ILAsm .NET Compiler Platform Native Image Generator (NGen) XAMLPad IDEs Visual Studio Blend Express MonoDevelop SharpDevelop Xamarin Studio Organizations .NET Foundation Microsoft Xamarin Category List Commons

v t e Microsoft free and open-source software (FOSS) Overview Microsoft and open source Shared Source Initiative Software Applications 3D Movie Maker Atom Conference XP Family.Show File Manager Open Live Writer Microsoft Edit Microsoft PowerToys Terminal Windows Calculator Windows Console Windows Package Manager WorldWide Telescope XML Notepad Video games Allegiance Zork Programming languages Bosque C# Dafny F# F* GW-BASIC IronPython IronRuby Lean P Power Fx PowerShell Project Verona Q# Small Basic Online TypeScript Visual Basic Frameworks, development tools .NET .NET Framework .NET Gadgeteer .NET MAUI .NET Micro Framework AirSim ASP.NET ASP.NET AJAX ASP.NET Core ASP.NET MVC ASP.NET Razor ASP.NET Web Forms Avalonia Babylon.js BitFunnel Blazor C++/WinRT CCF ChakraCore CLR Profiler Dapr DeepSpeed DiskSpd Dryad Dynamic Language Runtime eBPF on Windows Electron Entity Framework Fluent Design System Fluid Framework Infer.NET LightGBM Managed Extensibility Framework Microsoft Automatic Graph Layout Microsoft C++ Standard Library Microsoft Cognitive Toolkit Microsoft Design Language Microsoft Detours Microsoft Enterprise Library Microsoft SEAL mimalloc Mixed Reality Toolkit ML.NET mod_mono Mono MonoDevelop MSBuild MsQuic Neural Network Intelligence npm NuGet OneFuzz Open Management Infrastructure Open Neural Network Exchange Open Service Mesh Open XML SDK Orleans Playwright ProcDump ProcMon Python Tools for Visual Studio R Tools for Visual Studio RecursiveExtractor Roslyn Sandcastle SignalR StyleCop SVNBridge T2 Temporal Prover Text Template Transformation Toolkit TLA+ Toolbox U-Prove vcpkg Virtual File System for Git Voldemort VoTT Vowpal Wabbit Windows App SDK Windows Communication Foundation Windows Driver Frameworks KMDF UMDF Windows Forms Windows Presentation Foundation Windows Template Library Windows UI Library WinJS WinObjC WiX XDP for Windows XSP xUnit.net Z3 Theorem Prover Operating systems MS-DOS (v1.25, v2.0 & v4.0) Barrelfish SONiC Azure Linux Other ChronoZoom Extensible Storage Engine FlexWiki FourQ Gollum Project Mu ReactiveX SILK TLAPS TPM 2.0 Reference Implementation Windows Subsystem for Linux Licenses Microsoft Public License Microsoft Reciprocal License Forges CodePlex GitHub Related .NET Foundation F# Software Foundation Microsoft Open Specification Promise Open Letter to Hobbyists Open Source Security Foundation Outercurve Foundation Category

v t e Web frameworks Comparison .NET ASP.NET Core AJAX Dynamic Data MVC Razor Web Forms Blazor DNN BFC MonoRail Umbraco WebSharper C++ Drogon Wt ColdFusion ColdBox Platform Common Lisp CL-HTTP Haskell Servant Snap Yesod Java AppFuse Grails GWT ICEfaces JHipster JWt Mojarra Play Remote Application Platform Seam Sling Spring Stripes Struts Tapestry Vaadin Vert.x Wicket WaveMaker ZK JavaScript Back end Server-side Dojo Express.js Fastify Meteor NestJS Sails.js Full-stack Analog Next.js Nuxt Remix SvelteKit Front end Client-side Angular/AngularJS Backbone.js Blaze Closure Dojo Ember.js Ext JS htmx jQuery Knockout MooTools OpenUI5 Prototype Qooxdoo React React Router Sencha Touch SproutCore Svelte Vue.js comparison... Kotlin Jetpack Compose (Web) Ktor Perl Catalyst Dancer Maypole Mojolicious WebGUI PHP CakePHP CodeIgniter Drupal eZ Publish Fat-Free Flow FuelPHP Grav Gyroscope Horde Joomla! Laminas Laravel li₃ Midgard MODX Phalcon PHP-Fusion PHP-Nuke Pop PHP PRADO ProcessWire Qcodo Silverstripe Symfony TYPO3 WordPress XOOPS Yii Python BlueBream CherryPy CubicWeb Django FastAPI Flask Grok Nevow Pylons Pyramid Quixote Tornado TurboGears web2py Zope 2 more... Ruby Merb Padrino Ruby on Rails Sinatra Rust Rocket Scala Lift Play Scalatra Smalltalk AIDA/Web Seaside Other languages Application Express (PL/SQL) Grails (Groovy) OpenACS (Tcl) Phoenix (Elixir) Shiny (R) Yaws (Erlang)

---
Adapted from the Wikipedia article [ASP.NET Razor](https://en.wikipedia.org/wiki/ASP.NET_Razor) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/ASP.NET_Razor?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
