ASP.NET Core 2 Gains Razor Pages

| by Jeff Martin Follow 8 Followers on Aug 29, 2017. Estimated reading time: 2 minutes |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

Joining the release of .NET Core 2 and Entity Framework Core 2.0 is the third piece of the triad: ASP.NET Core 2.0.  This release provides several new features and improvements including general performance enhancements, Razor Pages, new development templates, and better support for Azure Diagnostics.


Let's take a look at Razor Pages first.  Razor pages resemble a standard MVC View, but use the @Page directive to indicate it is a Razor Page.  Microsoft now considers Razor Pages the recommended way to build UI for web applications in ASP.NET Core, but developers are of course free to choose the approach that works best for them.  Using Razor Pages allows web pages to be written that handle requests directly without going through a controller (as would be the case in a standard ASP.NET MVC application).


Another benefit of moving to ASP.NET Core 2 is the ability to take advantage of simplified package references.  Your project’s .csproj file need only reference Microsoft.AspNetCore.All which is a metapackage that ensures all of the libraries needed by your application are available without complicating the matter.  Publishing a web app will cause only the libraries your project needs to be distributed with your application, which avoids file bloat.  Another advantage to using the metapackage is that it enables faster application startup time through its use of the .NET Core Runtime Store, which precompiles all of the packages and files within it.  As this meta-package is intended as a conveince, it does not prevent developers from continuing to reference specific packages in Microsoft.AspNetCore.* directly.


To support the new features, the ASP.NET Core 2 templates have been expanded to include templates for Razor Pages (titled Web Application), Web API, MVC-based web applications, Angular, React.js and React.js & Redux.  All of these are also available via the command line and do not depend on Visual Studio 2017.


The Razor language engine supports the features of C# 7.1 when explicitly enabled.  To take advantage of these features, add this property to your project file: 


Afterwards, reload the solution for your changes to take effect.

Those planning to deploy their applications to Azure will notice that applications built for ASP.NET Core 2 require no modification to take advantage of Azure App Service.  This can be performed within VS2017 or directly from within the Azure portal.  


Developers with existing ASP.NET Core 1.X packages can consult Microsoft’s upgrade guide for migration details in upgrading their application to ASP.NET Core 2.0.  To use ASP.NET 2.0 download the .NET Core 2 SDK, which is available independently of VS2017.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you