Is User Authenticated?

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I need to check if a user is authenticated. I tried everything I could
think and find:

If Membership.ValidateUser("shapper", "27lamps11") Then
Response.Write(Request.IsAuthenticated.ToString)
Response.Write(My.User.IsAuthenticated.ToString)
Response.Write(Me.User.Identity.IsAuthenticated.ToString)
Else
Response.Write("# User is Not Authenticated #")
End If

I get "FalseFalseFalse".

What is going on?

Thanks,
Miguel
 
I have already explained to you that Authentication is not the same as validating Membership.

You will *always* get False when validating Membership data
against Authenticated users, who must login with Windows credentials.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Hi Juan,

It is working now. Could you tell me if this is the right way:
If Membership.ValidateUser("username", "pass") Then
FormsAuthentication.SetAuthCookie("shapper", True)
Response.Write(Request.IsAuthenticated.ToString)
Response.Write(My.User.IsAuthenticated.ToString)
Response.Write(User.Identity.IsAuthenticated.ToString)
Else
Response.Write("# User is Not Authenticated #")
End If

And can you tell me which code line should I use to verify if a user is
authenticated:
Request.IsAuthenticated.ToString, My.User.IsAuthenticated.ToString or
User.Identity.IsAuthenticated.ToString?

Thank You,
Miguel
 
re:
And can you tell me which code line should I use to verify if a user is authenticated:
Request.IsAuthenticated.ToString, My.User.IsAuthenticated.ToString or
User.Identity.IsAuthenticated.ToString?

Which ones return valid responses ?
You can use any which return valid responses.

Remember, they will only produce valid results if you're using Forms Authentication and Membership.
They will *not* authenticate a user if you're using Windows Integrated Security.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
Hi Juan,

It is working now. Could you tell me if this is the right way:
If Membership.ValidateUser("username", "pass") Then
FormsAuthentication.SetAuthCookie("shapper", True)
Response.Write(Request.IsAuthenticated.ToString)
Response.Write(My.User.IsAuthenticated.ToString)
Response.Write(User.Identity.IsAuthenticated.ToString)
Else
Response.Write("# User is Not Authenticated #")
End If

And can you tell me which code line should I use to verify if a user is
authenticated:
Request.IsAuthenticated.ToString, My.User.IsAuthenticated.ToString or
User.Identity.IsAuthenticated.ToString?

Thank You,
Miguel
 
Back
Top