We can see HTML is still an essential part of Blazor, but the @code directive is now where we can add properties, methods, and general logic to our Blazor pages. Apart from the infrastructural differences, the Razor syntax used in ASP.NET Core MVC and Razor Pages is identical. Many MVC-style applications can be ported to Razor Pages with little modification to the views, apart from link generation, which now uses references to pages rather than controllers and actions. Razor Pages is a highly-opinionated approach to building web applications, leaning heavily on the lessons learned from years of developing with the MVC razor developers framework. Razor Pages drops the ceremony of controllers and takes a more page-focused mindset. Razor is a markup syntax that flows seamlessly between Hypertext Markup Language (HTML) and C# and Visual Basic syntax, with C# being the most commonly used.
The Runtime-only installation is intended for use on machines where no development takes place. Khalid is a developer advocate at JetBrains focusing on .NET technologies and tooling. I’ve written about generating HTML from Razor without a framework, which is a rugged use case for background workers. Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.
While built on top of a foundation of C# syntax, .NET continues to add reserved keywords to improve the developer experience. Some of these keywords are specific to the context in which developers are using Razor. Developers just starting their ASP.NET web development journey might have heard the term Razor, and had developers apply it within many different situations.
About Khalid Abuhakmeh
There are more C# constructs useable within Razor, such as if/else blocks, switch statements, looping constructs, comments, and more. Developers can find a detailed listing of Razor syntax at the official Microsoft Documentation site. Razor Pages is the recommended framework for cross-platform server-side HTML generation. Razor pages have much of the same syntax as ASP.NET MVC Razor views, with few exceptions. The syntax of Razor is recognizable through multiple reserved symbols and keywords that allow developers to transition into the scope of C# and back out to HTML, the most prominent being the @ symbol. It has the power of traditional ASP.NET markup, but it is easier to use, and easier to learn.
Getting Started with Razor
Architecturally, Razor Pages is an implementation of the MVC pattern and encourages separation of concerns.
Web Building
- Blazor is another technology within the ASP.NET Core family that relies on Razor syntax.
- Adopters of Razor Pages will interact with concepts like rendering HTML, model binding, and request/response handling.
- I’ve written about generating HTML from Razor without a framework, which is a rugged use case for background workers.
- The Razor syntax within the component is where Blazor and previously mentioned approaches start to differ.
The MVC usage of Razor is likely the syntax and patterns developers will be most familiar with as it’s been around the .NET community the longest. It is critical to note that many of the constructs are MVC specific, and that can be confusing for some when trying to understand where Razor the syntax starts and where ASP.NET Core MVC the framework begins. Introduced as part of ASP.NET Core, and now included in .NET 5, ASP.NET Razor Pages is a server-side, page-focused framework that enables building dynamic, data-driven web sites with clean separation of concerns. Part of the ASP.NET Core web development framework from Microsoft, Razor Pages supports cross platform development and can be deployed to Windows, Unix and Mac operating systems. The Razor syntax within the component is where Blazor and previously mentioned approaches start to differ.
Blazor focuses on the .NET developers’ experience, translating C# logic which many Razor users are familiar with, into dynamic user experiences. If you choose to build your own, you can choose from a wide range of programming languages and frameworks. If you are a beginner, you will probably want to start with a framework and language that is easy to learn, well supported and robust. If you are considering making a career as a programmer, you probably want to know that the skills you acquire while learning your new framework will enhance your value to potential employers. In both cases, learning C# as a language and ASP.NET Core as a framework will tick those boxes.