日期:2014-05-17 浏览次数:21006 次
routes.MapRoute(
"Default", // 路由名称 唯一
"news/{id}/{page}", // 带有参数的 URL
new { controller = "News", action = "List", id = UrlParameter.Optional, page = UrlParameter.Optional } // 参数默认值
);
public class NewsController : Controller
{
public ActionResult List(int id, int page)
{
ViewBag.id = id;
ViewBag.page = page;
return View();
}
}
@{
ViewBag.Title = "List";
}
<h2>List</h2>
id:@ViewBag.id
page:@ViewBag.page
a: @Html.ActionLink("link","News","List");
href:<a href="@Url.Action("List","News")">link</a>