S
sean
I'm attempting to use Forms/Roles based authentication and
authorization. A subdirectory's web.config allows only
"Admin" roles and it does kick browsers to a login page.
However...when supplying proper credentials to the login
page I'm never actually redirected to the page in the
protected subdirectory. I've stepped through the code in
the debugger and I can see the connection to the db open
and the names of the roles getting fed to a cookie all just
fine but at the last the redirect never happens. There's a
blink (postback I'm assuming) and I stay at the login page.
Any help greatly appreciated. Code to follow..
..........................................................
web.config of protected directory:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authorization>
<allow roles="Administrator" />
<deny users="*" />
</authorization>
</system.web>
</configuration>
..........................................................
..........................................................
code in login.aspx onClick event handler:
Dim cookieRoles As New StringBuilder
While reader.Read()
cookieRoles.Append(reader("Role").
ToString())
cookieRoles.Append(".")
End While
' Save the Roles in a client Cookie for
future requests
Dim RoleCookie As HttpCookie = New
HttpCookie("Roles")
RoleCookie.Value = cookieRoles.ToString()
Response.Cookies.Add(RoleCookie)
FormsAuthentication.
RedirectFromLoginPage(UserName.Text, PersistCookie.Checked)
..........................................................
authorization. A subdirectory's web.config allows only
"Admin" roles and it does kick browsers to a login page.
However...when supplying proper credentials to the login
page I'm never actually redirected to the page in the
protected subdirectory. I've stepped through the code in
the debugger and I can see the connection to the db open
and the names of the roles getting fed to a cookie all just
fine but at the last the redirect never happens. There's a
blink (postback I'm assuming) and I stay at the login page.
Any help greatly appreciated. Code to follow..
..........................................................
web.config of protected directory:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authorization>
<allow roles="Administrator" />
<deny users="*" />
</authorization>
</system.web>
</configuration>
..........................................................
..........................................................
code in login.aspx onClick event handler:
Dim cookieRoles As New StringBuilder
While reader.Read()
cookieRoles.Append(reader("Role").
ToString())
cookieRoles.Append(".")
End While
' Save the Roles in a client Cookie for
future requests
Dim RoleCookie As HttpCookie = New
HttpCookie("Roles")
RoleCookie.Value = cookieRoles.ToString()
Response.Cookies.Add(RoleCookie)
FormsAuthentication.
RedirectFromLoginPage(UserName.Text, PersistCookie.Checked)
..........................................................