Search code examples
c#asp.net-coreurl-routingrazor-pages

How to make this URL pattern acceptable in ASP.NET Core?


I am working in an ASP.NET Core project with Razor pages and I am trying to make this URL pattern

/{clientName}/Forms/{page}

acceptable to route. You should know I'm using Razor Pages NOT MVC.

  • clientName is any string
  • Forms is area
  • page is any page in forms area

I did something similar in MVC, but it didn't work for me in this case.

Now I want to get clientName in OnGet method. How can I do this?

What are the changes I should add to Program.cs?


Solution

  • Change the name of the page parameter to something like pageName. page is a reserved word in Razor Pages.