简体   繁体   English

ASP.NET路由和CMS

[英]ASP.NET ROUTES AND CMS

I have already managed to get friendly urls working with my cms; 我已经设法获得与我的cms一起使用的友好网址; however, what i want to know is: with asp.net 4.0 routes options, how do i get a root leaving routing? 但是,我想知道的是:使用asp.net 4.0路由选项,如何获得离开路由的根目录? When user types in www.mysite.com/page_name, which is aboutus, it goes to the page cms.aspx but leaves the other routes intact: 当用户键入约usus.mysite.com/page_name时,它将转到cms.aspx页面,但其他路由保持不变:

        routes.Clear();
        // Register a route for Products/{ProductName}
        routes.MapPageRoute(
            "View Product",             // Route name
            "Products/{ProductName}",   // Route URL
            "~/products.aspx"        // Web page to handle route
        );


        // Register a route for Products/{ProductName}
        routes.MapPageRoute(
            "ShoppingCart",       // Route name
            "{ShoppingCart}",   // Route URL
            "~/Basket.aspx"        // Web page to handle route
        );


        // Register a route for Products/{ProductName}
        routes.MapPageRoute(
            "ShoppingCart",       // Route name
            "{ShoppingCart}",   // Route URL
            "~/Basket.aspx"        // Web page to handle route
        );

  // --->> How do i do this

  // Register a route for url/{pagename}
        routes.MapPageRoute(
            "cms",       // Route name
            "{}",   // Route URL
            "~/cms.aspx"        // Web page to handle route
        );

I think you're looking for a root controller. 我认为您正在寻找根控制器。 This will allow you to eliminate the controller name and just have: {url}/action It sounds like your intention is to clean up the URL's? 这将允许您消除控制器名称,而只需要执行以下操作:{url} / action听起来您打算清除URL?

See: Having trouble with a simple MVC route 请参阅: 使用简单的MVC路由时遇到麻烦

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM