路由值繫結
給出一些預設路由,如 {controller=Home}/{action=Index}/{id?}
,如果你有 url https://stackoverflow.com/questions/1558902
這將轉到 QuestionsController,值 1558902 將對映到索引操作的 id 引數,即
public ActionResult Index(int? id){
//id would be bound to id of the route
}
給出一些預設路由,如 {controller=Home}/{action=Index}/{id?}
,如果你有 url https://stackoverflow.com/questions/1558902
這將轉到 QuestionsController,值 1558902 將對映到索引操作的 id 引數,即
public ActionResult Index(int? id){
//id would be bound to id of the route
}