asp.net mvc 之获取地址栏参数

方法有两种

test1的view页面

@html.actionlink("参数传递","test2/1","html")

1在test2 的controller中获取

public ActionResult test2(int id)
{
ViewData["id"] = id;

return View();
}

2在test2的view 中获取

@html.viewcontext.routedata.values["id"]

 上面写的格式不规范应该这样@hml.actionlink("a","index","home",new {id=1,id2=3})

原文地址:https://www.cnblogs.com/dh2014/p/4821125.html