我有包含Login Method的UsersController,并且在NEWSController中有AfterLogin方法。 ActionResualt登录UsersController:
public ActionResult Login(Users U)
{
if (ModelState.IsValid)
{
using (NEWSDBContext DB = new NEWSDBContext())
{
var v = DB.Userss.Where(a => a.UserName.Equals(U.UserName) && a.PassWord.Equals(U.PassWord)).FirstOrDefault();
if (v != null)
{
Session["LogedUserID"] = v.UserID.ToString();
// var SessionUserID = System.Web.HttpContext.Current.Session["LogedUserID"];
Session["LogedUserFullname"] = v.Name.ToString() + " " + v.Family.ToString();
return RedirectToAction("AfterLogin","NEWS");
}
}
}
return View(U);
}
ActionSesualt AfterLogin in NEWSController:
public ActionResult AfterLogin()
{
ViewBag.message = Session["LogedUserFullname"].ToString();
int id = int.Parse(Session["LogedUserID"].ToString());
var kh=from n in db.NEWSs where n.UserID.Equals(id) select n;
// NEWS news = db.NEWSs.Find(id);
return View(kh.ToList());
}
现在我想点击登录按钮显示包含AfterLogin信息的jQuery DataTable。