1

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?

1
  • Hello, have you tried the suggestion offered by Mike? Did you able to make any progress on this? Commented May 23, 2024 at 8:23

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

let me explain. I want the route to be like this localhost:7161/xyz/Forms/CreateApp. I want to get to all Pages in Forms Area, so I did {page} in the route
Yes, but page is a reserved word and cannot be used as a parameter name in Razor Pages. If you change it to /{clientName}/Forms/{pageName} "CreateApp" will be bound to the pageName route value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.