3
My login
Dim senha = "null"
If Not (senhaLogin.Text = "") Then
senha = senhaLogin.Text
End If
Dim Usuario = GetUsuario.Where(Function(a) a.Email = emailLogin.Text And a.Senha = senha)
If Usuario.Count > 0 Then
Dim userName = Usuario.FirstOrDefault().ID
FormsAuthentication.SetAuthCookie(userName, False)
Response.Redirect("Default.aspx")
End If
My validation checking if the user is authenticated
Dim ID = System.Web.HttpContext.Current.User.Identity
If ID.Name = "" Then
Response.Redirect("login.aspx")
End If
My problem is I always get the ID.Name
as null.
In your User method.Firstordefault(). ID is returning something? Because I did it here in C#, pretty much the same and it worked. In my opinion I think that if you remove . Firstordefault() and put only User.ID will work.
– Marconi
Does your user really exist? Your Getusuario method is returning something?
– Marconi