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 stringForms
is areapage
is any page in forms area
I did something similar in MVC, but it didn’t work for me in this case.
I found this code:
app.MapGet("/{clientName}/Forms/{page}", (string clientName, string page) =>
{
return Results.Ok($"cleintName: {clientName}, Page:{page}");
});
and it runs perfectly, but the OnGet
didn’t get executed.
Now I want to get clientName
in OnGet
method. How can I do this?
What are the changes I should add to Program.cs
?