Routing

public void RegisterRoutes(RouteCollection routes) {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
        "Default",                                       // Route name
        "{controller}/{action}/{id}",                    // URL w/ params
        new { controller="Home", action="Index",id="" }  // Param defaults
    );
}

---------------------------------------------------------------------------------

|          URL             Controller Class      Action Method    Parameters Passed   |

---------------------------------------------------------------------------------
/Dinners/Details/2    DinnersController    Details(id)           id=2
/Dinners/Edit/5        DinnersController    Edit(id)               id=5
/Dinners/Create       DinnersController    Create()              N/A
/Dinners                 DinnersController    Index()               N/A
/Home                    HomeController       Index()               N/A
/                            HomeController       Index()               N/A

posted @ 2012-09-17 10:26  webglcn  阅读(167)  评论(0编辑  收藏  举报