2008-12-07 281 views

回答

4

假設一個C#開發環境

的Global.asax:

routes.MapRoute(
    "Bookmarks", 
    "bookmarks", 
    new { controller = "Bookmarks", action = "Bookmarks"} 
); 

routes.MapRoute(
    "Bookmark", 
    "bookmark/{bookmarkid}", 
    new { controller = "Bookmarks", action = "Bookmark" } 
); 

BookmarksController:

public ActionResult Bookmarks() 
{ 
    //Get all bookmarks, I presume. :) 
    return View(); 
} 

public ActionResult Bookmark(string bookmarkid) 
{ 
    //Do stuff with the bookmark id 
    return View(); 
} 

使用此路由方案,http://localhost/bookmarks會打在書籤行動書籤控制器和http://localhost/bookmark/123456將點擊書籤控制器中的書籤操作。

+0

非常感謝。不知道你能做到這一點。 – NabilS 2008-12-07 17:23:37