User.Identity.IsAuthenticated return true

Z

Zulander

Hi, For some reason my session are expireing when the web browser
closes and User.Identity.IsAuthenticated is truning true,
I have a webcrontrol from login:

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn
Dim UserTicket As FormsAuthenticationTicket = New
FormsAuthenticationTicket(1, Login1.UserName, DateAndTime.Now,
DateAndTime.Now.AddSeconds(1), False, "WebUser",
FormsAuthentication.FormsCookiePath)
FormsAuthentication.Encrypt(UserTicket)
end sub

and in my secure page i have tha fallowing:


Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not User.Identity.IsAuthenticated Then
FormsAuthentication.RedirectToLoginPage()
Exit Sub
End If

did i do anything wrong ?

p.s: my authentication type is :form !
thank you
 
T

Tim_Mac

hi zulander,
can you post your web.config? i usually secure pages or folders via
web.config with a <locations> setting instead of by code.
i know you said you have Forms Auth in your web.config, but it looks like
that isn't set up correctly, or else the Forms ticket is still valid in
Page_Load.
also, why are you granting the ticket for 1 second?
it may help to find out what User.Identity.Name is in your Page_Load, it
could be the IIS guest account or the Forms user.

tim
 
Z

Zulander

Tim_Mac, This is my web.config

<authentication mode="Forms">
<forms loginUrl="login.aspx"/>
</authentication>


<location path="login.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>

The part with the one second is that i was testing if it was the cause
of not expiring,
it was actualy: Dim UserTicket As FormsAuthenticationTicket =
New FormsAuthenticationTicket(1, Login1.UserName, DateAndTime.Now,
DateAndTime.Now, False, "WebUser", FormsAuthentication.FormsCookiePath)

The, user is the authenticated user that was loged therfore it is not
the guest account !
thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top