2013-07-19 46 views

回答

1

如果你想迫使它使用查询字符串,那么只需从它中删除任何参数的概念,URL结构通常由路由决定,例如,

routes.MapRoute(
    "EditPostRoute", 
    "Post/EditPost", 
    new { controller = "Edit", action = "EditPost" } 
); 

您的@Html.ActionLink代码应该生成.../Post/EditPost?ID=32

0

更改操作将参数从int编辑为string。然后,它会显示你想要的

public ActionResult Edit(string ID) 
{ 
    ======= 
    ======= 
} 

@Html.ActionLink("Edit", "EditPost", new { ID = item.PostID },null) 

另一种解决方案 从Global.asax/Route Table

删除 id = UrlParameter.Optional
相关问题