Asp.net core Razor页面中基于URL参数的路由
这是一个非常简单的问题,但我的搜索结果并没有给出预期的答案。我有一个网址:Asp.net core Razor页面中基于URL参数的路由,asp.net-core,routing,razor-pages,Asp.net Core,Routing,Razor Pages,这是一个非常简单的问题,但我的搜索结果并没有给出预期的答案。我有一个网址: http://localhost/customers 显然,这会映射到“Customers”文件夹中的Index.cshtml文件 我想要另一个网址: http://localhost/customers/<CustomerID> http://localhost/customers/ 要映射到另一个页面/Customers/Detail.cshtml 如何在.NET Core 3.0中配置路由,以便请
http://localhost/customers
显然,这会映射到“Customers”文件夹中的Index.cshtml文件
我想要另一个网址:
http://localhost/customers/<CustomerID>
http://localhost/customers/
要映射到另一个页面/Customers/Detail.cshtml
如何在.NET Core 3.0中配置路由,以便请求
http://localhost/customers/
将路由到Detail.cshtml?在Details.cshtml文件中使用覆盖路由:
您可以在Razor页面中阅读有关覆盖路由的内容:完美,这正是我所寻找的,链接帮助很大!对于未来的访问者,链接到此页面的锚定标记如下所示:
@page "/customers/{id:int}"