c# - Latest logged in date mvc -
the code working , saving down last time user logged in, problem can't log in. it's loading short time when trying log in , still seeing login view not view supposed see after(when login succeeded).
// get: /account/login [allowanonymous] public actionresult login(string returnurl) { viewbag.returnurl = returnurl; return view(); } // // post: /account/login [httppost] [allowanonymous] [validateantiforgerytoken] public async task<actionresult> login(loginviewmodel model, string returnurl, applicationuser app) { if (!modelstate.isvalid) { app = db.users.singleordefault(u => u.username == model.email); app.lastloggedin = datetime.now; db.entry(app).state = entitystate.modified; db.savechanges(); return view(model); }
what wrong code?
when use
return view(model);
you returning in fact
return view("name of current method/view", model);
and in case:
return view("login", model);
what want return view user supposed see after logging in:
return view("/viewthatrequiresloggedinuser");
Comments
Post a Comment