【发布时间】:2011-08-07 18:36:54
【问题描述】:
我在使用 ASP .NET 路由时遇到了一个令人震惊的问题。我不知道这是 Microsoft 代码中的错误,还是我只是用错了。
场景基本上是这样的:
我想添加一条自定义路线。此外,我正在注册 ASP .NET DynamicDataRoutes。如果我省略了自定义路由,所有 ASP .NET DynamicDataRoutes 都可以正常工作。一旦我在DynamicDataRoute 之前添加了这个:
routes.Add(new Route("IgnoreDirectory/{*pathInfo}"), new StopRoutingHandler()));
DynamicData 生成的所有 DynamicHyperlinks 都是用错误的根 url 生成的,比如这个:
http://localhost/IgnoreDirectory/MyTable/List
应该是(直到我添加了我的自定义路线)
http://localhost/MyDynamicData/MyTable/List
奇怪的是,我正在为完全不同的路径添加我的 DynamicDataRoute:
routes.Add(new DynamicDataRoute("MyDynamicData/{{table}}/{{action}}")
{
Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
Model = model
});
为什么为 IgnoreDirectory 添加路由会导致我的 DynamicData 路由使用 IgnoreDirectory 的基本 url????
我想不通。
【问题讨论】:
标签: asp.net url-routing dynamic-data asp.net-routing