2012-09-11 40 views

回答

4

添加以下路由到您的global.asax.cs的RegisterRoutes:

routes.MapRoute(
      "Book By Name", 
      "Book/Details/{bookName}", 
      new { controller = "Book", action = "BookDetails" } 
     ); 

你還需要有以下操作方法BookController

public Book BookDetails(string bookName) 
{ 
    // Your logic here to get a book by name and return it 
} 

或者你可以使用默認的路徑和BookController中創建Details(string id)操作方法來達到同樣的效果