Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliSense for Razor Pages routes

I was toying with new Razor Pages in ASP .NET Core 2.0 and noticed some problems with IntelliSense.

When using tag helper for MVC controller I get usual help:

MVC with IntelliSense

However there is no such help for asp-page tag helper used in Razor Pages:

razor Pages with no help

Is this a problem with my Visual Studio or rather Razor Pages tags do not support it yet?

I use ASP .NET Core 2.0 with framework 4.7 on VS 2017 15.5.5.

like image 633
Michal Sznajder Avatar asked Feb 08 '18 08:02

Michal Sznajder


People also ask

Can you use MVC with razor pages?

You can add support for Pages to any ASP.NET Core MVC app by simply adding a Pages folder and adding Razor Pages files to this folder. Razor Pages use the folder structure as a convention for routing requests.


Video Answer


1 Answers

It seems IntelliSense for routes is not supported (yet I hope), but there is an interesting workaround for that - see Razor Pages Url tt File. The idea is to create some SitePages.tt file in your ASP.NET Core 2 project using Razor Pages to scan the /Pages folder and output a class with string properties to get the IntelliSense for routes:

<cancel-button asp-page="@SitePages.DashboardIndex"></cancel-button>
like image 128
Dmitry Pavlov Avatar answered Oct 02 '22 16:10

Dmitry Pavlov