Search code examples
asp.net-corerazor-pages

Asp.Net Core Razor Pages Friendly URLs


Trying to get friendly URL's working with Razor Pages, here is my folder structure within the Pages folder:

/Products/Index.cshtml @page
/Products/View.cshtml @page "{id}/view"
/Products/Process.cshtml @page "{id}/process"

I'm linking from Index.cshtml to the other pages like this:

<a asp-page="/Products/View" asp-route-id="100">View</a>

<a asp-page="/Products/Process" asp-route-id="100">Process</a>

The generated urls are products/view/100/view and products/process/100/process.

Instead is it possible to generate them like products/100/view and products/100/process?

I've tried asp-page="View" asp-route-id="100", but that makes no difference.


Solution

  • grrr, jumped too soon, this worked:

    @page "/products/{id}/view"
    
    @page "/products/{id}/process"
    

    Coffee...