【发布时间】:2010-05-06 04:09:28
【问题描述】:
我的一个视图页面中有一个操作链接
<%=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 = "" }
);
【问题讨论】:
标签: asp.net-mvc url-routing detailsview