hello all,
I am having trouble with forms authentication. Any help would be greatly appreciated. I am setting the forms auth expiration to 2 minutes. But even after 2 minutes of inactivity in the home page it does not take me back to the login.aspx page. Am i missing something here?
Here's my vb.net code:
Login.aspx page
--------------------------------------------------------
'--------------------------------------------------------
My Web config file:
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="../common/logon.aspx" path="/" protection="All" timeout="30" slidingExpiration="true" />
</authentication>
Thanks,
MB
I am having trouble with forms authentication. Any help would be greatly appreciated. I am setting the forms auth expiration to 2 minutes. But even after 2 minutes of inactivity in the home page it does not take me back to the login.aspx page. Am i missing something here?
Here's my vb.net code:
Login.aspx page
--------------------------------------------------------
Code:
Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RollOver1.Click
If CheckUser(LogonUser, passwordUser) Then
SetFormsAuthentication(LogonUser)
Response.Redirect("../Common/Default.aspx", True)
End If
Catch ex As Exception
lblmessage.Text = ex.Message
End Try
End Sub
private function checkuser(username as string, password as string)
'if sql authenticated then returns true..else raises and error.
end function
Private Sub SetFormsAuthentication(ByVal username As String)
FormsAuthentication.Initialize()
Response.Cookies.Clear()
Dim expiration As Integer=2
Dim dt As DateTime = DateTime.Now
Dim dte As DateTime = dt.AddMinutes(expiration)
Dim tkt As FormsAuthenticationTicket = New FormsAuthenticationTicket(username, False, expiration)
Dim cookiestr As String = FormsAuthentication.Encrypt(tkt)
Dim ck As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, cookiestr)
Response.Cookies.Set(ck)
End Sub
'--------------------------------------------------------
My Web config file:
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="../common/logon.aspx" path="/" protection="All" timeout="30" slidingExpiration="true" />
</authentication>
Thanks,
MB