Getting the CurrentUserID from Websecurity directly after login (C#/ASP.NET) -
i have website (c#/asp.net) form user can register account (it default template of vs11) , after filled in , user clicks register, creates account , logs in user (which works great).
after step want userid assigned, doesn't work. i've put breakpoint there see values of both "currentuserid" , "websecurity.currentuserid" have -1 value. next step user gets redirected next page, , on page these functions work. thought able userid user has gotten logged in in first line of code provided here.
so question is, why doesn't work here? noobish this, missing something.
websecurity.login(username, password); int currentuserid = websecurity.currentuserid; // doesn't work, returns -1 <here wish update other tables need user id> response.redirect("~/welcome.cshtml");
thanks!
you should use websecurity.getuserid(username)
websecurity.login(username, password); int currentuserid = websecurity.getuserid(username); response.redirect("~/welcome.cshtml");
take here: http://msdn.microsoft.com/en-us/library/webmatrix.webdata.websecurity.getuserid(v=vs.99)
Comments
Post a Comment