1. 程式人生 > >ASP.NET MVC 入門3、Routing

ASP.NET MVC 入門3、Routing

publicstaticvoid RegisterRoutes(RouteCollection routes)
{
    
//忽略對.axd檔案的Route,也就是和WebForm一樣直接去訪問.axd檔案    routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

    routes.MapRoute(
        
"Category",                                              // Route 的名稱"Category/{action}/{categoryName}",                           
// 帶有引數的URLnew { controller ="Category", action ="Index", categoryName ="4mvc" }  // 設定預設的引數    ); 



protectedvoid Application_Start()
{
    
//在程式啟動的時候註冊我們前面定義的Route規則    RegisterRoutes(RouteTable.Routes);
}