How to use the url which hold a .html?

mc 4,376 Reputation points
2021-05-27T07:49:33.98+00:00

I am using asp.net core web with razor pages. I want to the url can be like

http://xxx.com/Manage/Index.html

https://xxx.com/Product/12.html

12 is the id or other params.

how to achieve it?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,507 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jerry Cai-MSFT 991 Reputation points
    2021-05-28T02:48:02.087+00:00

    Hi,65841535

    Pass the parameter using asp-route-XXX

    <a asp-page="/Privacy" asp-route-param="12">Go</a>  
    

    And in razor view, define the url like:

    @page  "{param}.html"  
    

    Then when going to privacy page, the parameter with the customized url will be showed in view.

    R9lzx.png

    About Route convention in razor page, you can check:
    razor-pages-conventions

    optional-parameters-in-razor-pages-routing

    Best Regards,
    Jerry Cai


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.