我在 global.asax 中定义了以下路线:
routes.MapRoute(
"Agreements2", // Route name
"Agreements2/{action}/{id}", // URL with parameters
new { controller = "Agreements", action = "AgreementSummery", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Agreements", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Agreements", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
后一条路线工作正常,但我不明白为什么第一条路线不起作用。
Agreements 控制器上的 AgreementSummery 方法定义为:
[HttpGet]
public ActionResult AgreementSummery(int? id)
{
AgreementsModel model = new AgreementsModel();
model.SelectedAgreementID = id.Value;
return View(model);
}