Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.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
C# 具有类似routeURL的MapPageRoute_C#_Asp.net_C# 4.0 - Fatal编程技术网

C# 具有类似routeURL的MapPageRoute

C# 具有类似routeURL的MapPageRoute,c#,asp.net,c#-4.0,C#,Asp.net,C# 4.0,我需要在我的应用程序中发生这种重定向: /汽车 转到show-all-cars.aspx /汽车/1234 转到edit-car.aspx 这是我在global.asax中的当前代码: routeCollection.MapPageRoute("car-edit", "car/{id}", "~/car-edit.aspx", true, new RouteValueD

我需要在我的应用程序中发生这种重定向:

/汽车 转到show-all-cars.aspx

/汽车/1234 转到edit-car.aspx

这是我在global.asax中的当前代码:

routeCollection.MapPageRoute("car-edit",
                "car/{id}",
                "~/car-edit.aspx",
                true,
                new RouteValueDictionary { { "id" } });

routeCollection.MapPageRoute("car-all",
                "car",
                "~/show-all-cars.aspx",
                true);
出于某些原因,转到/car会导致重定向到car-edit.aspx,而不是根据需要显示-all-cars.aspx

有什么想法吗


Webforms C#.NET 4.0只需交换两个路由,即将第二个路由放在第一个路由之前