Template for new ASP.NET Core Razorpage in Visual Studio 2017

973 views Asked by At

Starting to work with a web app and following the steps here to use razor pages

Is there a template (either in VS or elsewhere) for adding a new razorpage (ie the cshtml and the cshtml.cs files)? As a workaround I created an MVC View page (with the .cshtml ext) and then created a .cs file and renamed it to match the naming pattern.

I'm having problems running the scaffolding as well but that is a separate issue.

1

There are 1 answers

3
Kirk Larkin On BEST ANSWER

You can do this in the latest version of Visual Studio 2017 just by using Add New Item and choosing Razor Page.

You can also use dotnet new. For example:

dotnet new page --name MyPage

See the documentation for dotnet new. You can always get started by just running dotnet new alone to see the available templates.