.CS中代码
public ActionResult Index(string viewname, bool partial = false) { //获取URL中的 foreach (var key in Request.QueryString.AllKeys) { ViewData[key] = Server.UrlDecode(Request.QueryString[key]); } if (partial) { return PartialView(viewname); } //获取session 中的 ViewData["UserId"] = CurrentUser.HR_ID; return View(viewname); }
.cshtml中代码
@ViewData["UserId"]