MVC - 在应用程序启动时导航到home

时间:2011-08-23 19:15:09

标签: asp.net-mvc iis-6 routes

我在路线表中添加了以下路线。

routes.MapRoute(
            "Default",                                             
            "{controller}.aspx/{action}/{id}",                      
            new { action = "Index", id = "" } 
        );

        routes.MapRoute(
            "Root",    
            "",        
            new { controller = "Home", action = "Index", id = "" } 
        );

        routes.MapRoute(
            "Home",                                                 
            "Index",                                         
            new { controller = "Home", action = "Index", id = "" }  
        );

我可以导航到主页(手动)。但是应用程序不会在app start上导航。

有什么想法吗?感谢。

1 个答案:

答案 0 :(得分:1)

此代码块只能更改路由器名称

routes.MapRoute(
        ".netx",
        "{controller}.aspx/{action}/{id}",
        new
        {
            action = "Index",
            id = ""
        });


        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

请确保在申请开始页面

and please be sure on the application start page