我的一个视图页面中有一个操作链接
<%=Html.ActionLink("Details", "Details", new { id = Model.Id })%>
并将我重定向到具有这样http://localhost:1985/Materials/Details/2
而不是这样的 url 的页面我想将我的 url 作为http://localhost:1985/Materials/Details/steel
材料名称而不是 Id ...这可能吗......这是我的控制器操作方法,
public ActionResult Details(int id)
{
var material = consRepository.GetMaterial(id);
return View("Details", material);
}
编辑: 我正在迭代从 jsonresult 控制器返回的 json 对象....
$.each(data.Results, function() {
divs += '<a href="/Materials/Details/' + this.Id + '">Details</a>
<a href="/Materials/Edit/' + this.Id + '">Edit</a></div>';
});
我的路线是这样的,
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Materials", action = "Index", id = "" }
);