
- Building your first asp.net core mvc app with visual studio for mac registration#
- Building your first asp.net core mvc app with visual studio for mac code#
The Razor markup looks similar to an MVC view however, there is a unique directive placed at the top of the file to give it the features of a Razor Page.
Building your first asp.net core mvc app with visual studio for mac code#
Unlike MVC, which breaks into three separate components, a Razor page is made up of two pieces, a Razor markup file and a C# code file. If you would like to read more about the Razor Syntax, Tag Helpers, or any other features provided by Razor View Engine, I recommend reading through the Microsoft documentation. NET Core web application frameworks and focuses solely on generating HTML markup and rendering data objects. While Razor is front and center in the name of the new “Razor Pages” framework, it is just a piece of the puzzle. What does all this mean? The Razor templating syntax has been around for a long time. Second, markup gets generated server-side so, we don’t want to get Razor confused with Blazor. First, Razor is not unique to Razor Pages. As we unpack the previous sentence, there are two things to keep in mind. What is Razor? Razor is a server-side templating engine that allows developers to use C# to generate data-driven markup.

Just like MVC, Razor Pages uses Razor as it’s templating engine. The Razor View Engineīefore we go any further, let’s talk about a fundamental concept. This routing paradigm is different in MVC, where requests get routed to a controller who generates a modelfor a viewto data bind. In Razor Pages, each request gets routed directly to a page. Right off the bat, you will notice that Razor Pages follows a much more compact programming model than MVC does. Running the Razor Pages template gives us the same web application that our MVC template did. If these pages look familiar, they should. Expanding this folder, we can see that we start with a few default pages. The ‘Pages’ FolderĪs you’d imagine, the Pages folder is where the Razor Pages reside. Next, let’s look at the most fundamental part of our new application, the Razor Pages. Furthermore, instead of using the MVC controller routing, Razor Pages are mapped with endpoint routing. We can see these changes reflected in the ConfigureServices method. Instead of configuring MVC controllers and views for dependency injection, Razor Pages need to be registered. If we understand the thought process behind the ConfigureServices and Configure methods, the changes we see in the startup class make perfect sense. Public void Configure(IApplicationBuilder app, IWebHostEnvironment env) Public void ConfigureServices(IServiceCollection services) Now, let’s look at how the startup class differs in an ASP.NET Core Razor Pages application.
Building your first asp.net core mvc app with visual studio for mac registration#

Remember, we are responsible for all the code we generate, whether made from a new project template, created by scaffolding or hand-coded. While some of this code is considered to be “boilerplate” code, we must understand it.

To touch on the essential components, we reviewed everything that gets scaffolded in a new project. This framework is battle-hardened and has been around since early 2009. In my previous post, we discussed the ASP.NET Core Model-View-Controller (MVC) web application framework and what better way to start our journey through ASP.NET Core.
