0

我正在使用 .Net 4.0 框架并进行一些 url 路由。这不是一个 MVC 项目,而是一个 webforms 项目。我在 Global.asax 中创建了两条路线,如下所示:

        routes.MapPageRoute(
           "review",      // Route name
           "documents/{type}",      // Route URL
           "~/default.aspx" // Web page to handle route
        );

        routes.MapPageRoute(
           "help",      // Route name
           "resource/help",      // Route URL
           "~/help.aspx" // Web page to handle route
        );

当我单击站点导航中的链接(例如“文档/待定”)时,它将转到正确的位置并显示预期的 URL。如果我再次点击“文档/接受”,网址将如下所示:

http://localhost/documents/documents/accepted

也找不到该页面并呈现该页面。如果我单击帮助链接然后单击文档,也会发生同样的事情。网址将如下所示:

http://localhost/resource/documents/pending

为什么路由连接url?我怎样才能解决这个问题?

提前致谢

4

1 回答 1

0

The problem's to do with how your URLs are being resolved. For ways to guarantee your URLs are always resolved correctly see http://msdn.microsoft.com/en-us/library/dd329551.aspx.

Alternatively, I've written a Navigation project that will make your life much easier because it handles all URL building for you, http://navigation.codeplex.com/ . If you're interested and want any help, just let me know.

于 2012-06-02T17:03:15.370 回答