how to custom the url of each page in razor pages?

mc 5,491 Reputation points
2023-05-06T01:59:51.41+00:00

there is Index I want to set the route index.html

http:\localhost:20572\index.html

if the page is \Solution I want it be 'solution.html'

in @page directive how to do it?

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Konstantinos Passadis 19,591 Reputation points MVP
    2023-05-06T08:43:04.9233333+00:00

    Hello @mc !

    If you are using Razor Pages in ASP.NET Core, you can specify the route for a page using the @page directive. To set the route for index.html to the root URL, and the route for solution.html to /Solution, you can use the following @page directives in the respective Razor Pages:

    For index.html:

    @page "/"

    This sets the route for index.html to the root URL.

    For solution.html:

    @page "/Solution"

    This sets the route for solution.html to /Solution.

    You can add these directives at the top of your Razor Pages


    Assisting Source: ChatGPT Subscription

    Kindly mark the answer as Accepted and Upvote in case it helped or post your feedback to help !

    Regards

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.