开发者

ASP.NET Routing Interference Problems

I'm having a mind shattering problem with ASP .NET routing. I can't tell if this is a bug in Microsoft code or if I'm just using it wrong.

The scenario is basically this:

I have a custom route I want to add. In addition, I'm registering ASP .NET DynamicDataRoutes. If I leave out my custom route, all the ASP .NET DynamicDataRoutes work fine. Once I add this before my DynamicDataRoute:

routes.Add(new Route("IgnoreDirectory/{*pathInfo}"), new StopRoutingHandler()));

all the DynamicHyperlinks generated by DynamicData are generated with the wrong root url, like this one:

http://localhost/IgnoreDirectory/MyTable/List

which should be (and was until I added my custom route)

http://localhost/MyDynamicData/MyTable/List

What's weird is that I'm adding my DynamicDataRoute for a COMPLETELY different path:

routes.Add(new DynamicDataRoute("MyDynamicData/{{table}}/{{action}}")
                {
                    Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
                    Model = model
                });

Why is adding a route for IgnoreDirectory causing my DynamicData routes to use a base url of Ignor开发者_开发百科eDirectory????

I can't figure it out.


I'm going out on a limb here, but I think it has to do with two things. The order that the routes are stored in the RouteTable are significant in that the application will use the first route it finds in order to match the URL.

What I think might be happening here is that the DynamicDataRoute is building itself upon the Route that you are inserting before the DynamicDataRoute in the route table.

The first thing I would do is try moving the Route add after the DynamicDataRoute has been added.

Hope this helps...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜