路由设置下不同路径

FileUpload/Index页面加上以下标签

<a href="Book/Index">Book/Index</a>

路由设置为:

routes.MapRoute(
                "Default1", // 路由名称
                "Admin/Info/{controller}/{action}/{id}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
            );

            routes.MapRoute(
                "Default", // 路由名称
                "Admin/{controller}/{action}/{id}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
            );

            

            routes.MapRoute(
                "Defaultq", // 路由名称
                "{controller}/{action}/{id}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
            );

<a href="Book/Index">Book/Index</a>
url:http://localhost:6245/FileUpload/index
实际:http://localhost:6245/FileUpload/Book/Index
url:http://localhost:6245/admin/FileUpload/index
实际:http://localhost:6245/admin/FileUpload/Book/Index
url:http://localhost:6245/admin/info/FileUpload/index
实际:http://localhost:6245/admin/info/FileUpload/Book/Index

<a href="/Book/Index">Book/Index</a>
url:http://localhost:6245/FileUpload/Index
实际:http://localhost:6245/Book/Index
url:http://localhost:6245/admin/FileUpload/Index
实际:http://localhost:6245/Book/Index
url:http://localhost:6245/admin/info/FileUpload/index
实际:http://localhost:6245/Book/Index


<a href="../Book/Index">Book/Index</a>
url:http://localhost:6245/FileUpload/index
实际:http://localhost:6245/Book/Index
url:http://localhost:6245/admin/FileUpload/index
实际:http://localhost:6245/admin/Book/Index
url:http://localhost:6245/admin/info/FileUpload/index
实际:http://localhost:6245/admin/info/Book/Index

<a href="http://www.cnblogs.com/Book/Index">Book/Index</a>
url:http://localhost:6245/FileUpload/index
实际:http://localhost:6245/Book/Index
url:http://localhost:6245/admin/FileUpload/index
实际:http://localhost:6245/Book/Index
url:http://localhost:6245/admin/info/FileUpload/index
实际:http://localhost:6245/admin/Book/Index

posted @ 2011-05-02 01:24  天平盛世  阅读(284)  评论(0编辑  收藏  举报