I have a WebMatrix
application and I am using WebSecurity.GetUserId(Http.Current.User.Identity.Name)
to grab the UserID
. Sometimes it returns the UserId
and then other times it returns a -1
. I have a login page therefore, it should be getting the UserId
of the person logged into the application.
Here is my code:
var UserId = WebSecurity.GetUserId(HttpContext.Current.User.Identity.Name);
var User = WebSecurity.CurrentUserName;
var UserEmail = WebSecurity.CurrentUserName;
var dbApp = Database.Open("ApplicationServices");
var selectUser = "SELECT UserId, UserName, Location FROM LocationTable, UserTable WHERE (UserId) = (@0) AND (UserLocation) = (Id)";
var person = dbApp.QuerySingle(selectUser, UserId);
Why isn't it consistent?