ASP.Net MVC route mapping

前端 未结 5 1841
独厮守ぢ
独厮守ぢ 2021-01-11 10:19

I\'m new to MVC (and ASP.Net routing). I\'m trying to map *.aspx to a controller called PageController.

routes.MapRoute(
   \"Pa         


        
5条回答
  •  余生分开走
    2021-01-11 11:00

    I just answered my own question. I had the routes backwards (Default was above page). Below is the correct order. So this brings up the next question... how does the "Default" route match (I assume they use regular expressions here) the "Page" route?

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

提交回复
热议问题