L
Leonard Rutkowski
Hello all,
I am trying to use Forms authentication. I have got it to work
successfully, when the login page, and the redirect page are in the same
virtual directory, however, I want to put the login page into a separate
directory. When the user logs in, they will be directed to an application,
that may be different for each user, and these applications will be in
separate virtual directories. When I try to login, the login page returns.
This seems to indicate that the authorization is not being passed on to the
application.
Here is my code:
Dim AppLogin As New AppLogin
If AppLogin.LoginIsAuthorized(txtClientNo.Text, _
txtUsername.Text, txtPassword.Text) Then
'FormsAuthentication.RedirectFromLoginPage("lrutkowski", False)
'FormsAuthentication.SetAuthCookie("lrutkowski", False)
Dim authTicket As New FormsAuthenticationTicket(1,
txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
'Dim authTicket As New FormsAuthenticationTicket(1,
"lrutkowski", DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
Dim encryptedTicket As String =
FormsAuthentication.Encrypt(authTicket)
Dim authCookie As New
HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
Response.Cookies.Add(authCookie)
Response.Redirect("/CustomerService/default.aspx")
Else
lblErrorMsg.Text = "Login is invalid"
End If
and here is my web.config:
<authentication mode="Forms">
<forms name=".gfdASPXAUTH"
path="/" loginUrl="/PortalLogin/PortalLogin.aspx"
protection="All" timeout="30"
requireSSL="false">
</forms>
</authentication>
<!-- AUTHORIZATION
This section sets the authorization policies of the application.
You can allow or deny access
to application resources by user or role. Wildcards: "*" mean
everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<deny users="?" />
<!-- <allow users="*" /> --> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
Thanks, Leonard
I am trying to use Forms authentication. I have got it to work
successfully, when the login page, and the redirect page are in the same
virtual directory, however, I want to put the login page into a separate
directory. When the user logs in, they will be directed to an application,
that may be different for each user, and these applications will be in
separate virtual directories. When I try to login, the login page returns.
This seems to indicate that the authorization is not being passed on to the
application.
Here is my code:
Dim AppLogin As New AppLogin
If AppLogin.LoginIsAuthorized(txtClientNo.Text, _
txtUsername.Text, txtPassword.Text) Then
'FormsAuthentication.RedirectFromLoginPage("lrutkowski", False)
'FormsAuthentication.SetAuthCookie("lrutkowski", False)
Dim authTicket As New FormsAuthenticationTicket(1,
txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
'Dim authTicket As New FormsAuthenticationTicket(1,
"lrutkowski", DateTime.Now, DateTime.Now.AddMinutes(60), False, "test")
Dim encryptedTicket As String =
FormsAuthentication.Encrypt(authTicket)
Dim authCookie As New
HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
Response.Cookies.Add(authCookie)
Response.Redirect("/CustomerService/default.aspx")
Else
lblErrorMsg.Text = "Login is invalid"
End If
and here is my web.config:
<authentication mode="Forms">
<forms name=".gfdASPXAUTH"
path="/" loginUrl="/PortalLogin/PortalLogin.aspx"
protection="All" timeout="30"
requireSSL="false">
</forms>
</authentication>
<!-- AUTHORIZATION
This section sets the authorization policies of the application.
You can allow or deny access
to application resources by user or role. Wildcards: "*" mean
everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<deny users="?" />
<!-- <allow users="*" /> --> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
Thanks, Leonard