In my ASP.NET Razor Pages project I have for my Post entity an Edit page in the Pages folder named PostEdit.cshtml
.
I want to get to it using the URL "/posts/edit/{id?}"
, so I have at the top of the page:
@page "/posts/edit/{id?}"
To avoid code duplication, I want to use the same page also for adding a new Post, having a different route presented to the user, "/posts/add"
.
But I cannot add multiple routes to a single Razor page, adding a second @page
directive gives an error.