R
Rob
I'm not sure if I'm missing something but my forms authentication
doesn't work. I'm trying to access my page and I should be redirected to
login.aspx but it just let's me access the page.
Here's my web.config code:
<authentication mode="Forms">
<forms name="login" loginUrl="login.aspx" protection="All"
timeout="15" />
</authentication>
<authorization>
<allow users="*" />
<deny users="?" />
</authorization>
My login page takes care of the login information:
Dim sql As String
sql = "SELECT username FROM contacts WHERE username ='" &
txtUsername.Text & "' AND password ='" & txtPassword.Text & "'"
Dim cn As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("CONN_STRING"))
Dim comm As SqlCommand = New SqlCommand(sql, cn)
comm.Connection.Open()
Dim reader As SqlDataReader =
comm.ExecuteReader(CommandBehavior.CloseConnection)
If reader.Read() Then
FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, True)
Else
lblMessage.Text = "Invalid User"
End If
This web config is in the same folder as my web pages so if I should try
to access "page1.aspx", I should be redirected to login.aspx.
Am I not correct or am I missing something.
Thanks for you help.
Rob
doesn't work. I'm trying to access my page and I should be redirected to
login.aspx but it just let's me access the page.
Here's my web.config code:
<authentication mode="Forms">
<forms name="login" loginUrl="login.aspx" protection="All"
timeout="15" />
</authentication>
<authorization>
<allow users="*" />
<deny users="?" />
</authorization>
My login page takes care of the login information:
Dim sql As String
sql = "SELECT username FROM contacts WHERE username ='" &
txtUsername.Text & "' AND password ='" & txtPassword.Text & "'"
Dim cn As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("CONN_STRING"))
Dim comm As SqlCommand = New SqlCommand(sql, cn)
comm.Connection.Open()
Dim reader As SqlDataReader =
comm.ExecuteReader(CommandBehavior.CloseConnection)
If reader.Read() Then
FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, True)
Else
lblMessage.Text = "Invalid User"
End If
This web config is in the same folder as my web pages so if I should try
to access "page1.aspx", I should be redirected to login.aspx.
Am I not correct or am I missing something.
Thanks for you help.
Rob