asp.net mvc - How to work by jQuery data table for reading data from another controller? -


i have userscontroller includes login method , there afterlogin method in newscontroller. actionresualt login in 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);     } 

actionresualt 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 n.userid.equals(id) select n;        // news news = db.newss.find(id);          return view(kh.tolist());     } 

now want when click on login button display jquery datatable include information of afterlogin.


Comments