【发布时间】:2011-01-03 02:08:59
【问题描述】:
使用提供的默认路由,我不得不将我的参数命名为“id”。这对我的很多控制器动作来说都很好,但我想在某些地方使用更好的变量命名。我可以使用某种属性,以便在我的操作签名中拥有更有意义的变量名称吗?
// Default Route:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
// Action Signature:
public ActionResult ByAlias(string alias)
{
// Because the route specifies "id" and this action takes an "alias", nothing is bound
}
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-routing