使用提供的默认路由,我不得不命名我的参数“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
}
这是使用绑定的最好的例子,我找到了!有没有办法让这个模型属性的工作?即代替具有字符串参数的方法签名,它具有一个类作为具有如下所示的属性的参数:'[Bind(Prefix =“id”)] string Alias {get;设置;}'?这个例子不编译...我怎么修改它来编译(也是工作)? – 2011-09-08 17:00:18