Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core Razor页面中基于URL参数的路由_Asp.net Core_Routing_Razor Pages - Fatal编程技术网

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}"