Forms Authentication for multiple applications

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: cab0san (cabosan_at_gmail.com)
Date: 02/11/05


Date: 11 Feb 2005 12:54:27 -0800

I have several applications all on the same server. I would like them
to all use the same login page.

Example:
http://server1/customers/app1.aspx
http://server1/suppliers/byregion/app2.aspx

I have a login page located in the root of the same server:
http://server1/login.aspx

None of these are virtual directories.

The web.config file for customers/ and suppliers/byregion/ looks like
this:

<authentication mode="Forms">
 <forms loginUrl="/login.aspx" name=".ASPXAUTH" timeout="30" path="/"
protection="All">
 </forms>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>

The web.config for the root web looks like this
<authentication mode="Forms">
 <forms loginUrl="login.aspx" name=".ASPXAUTH" timeout="30" path="/"
protection="All">
 </forms>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>

Both apps are configured to allow anonymous in iis.

The login page code looks like this:

Dim tkt As FormsAuthenticationTicket
tkt = New FormsAuthenticationTicket(1, Me.txtUser.Text, DateTime.Now(),
DateTime.Now.AddMinutes(30), True, "<group info would go here>")
Dim cookiestr As String
cookiestr = FormsAuthentication.Encrypt(tkt)
Dim ck As HttpCookie
ck = New HttpCookie(".ASPXAUTH", cookiestr)
ck.Expires = tkt.Expiration
ck.Path = "/"
Response.Cookies.Add(ck)
Dim strRedirect As String
strRedirect = Request("ReturnURL")
Response.Redirect(strRedirect)

When I request a page in customers, like
http://server1/customers/app1.aspx, I am redirected to the login page
(good), bet when I click logon and run the above code, it just returns
to the login page again (bad).
The "ReturnURL" is correct, as I have seen in debug mode.

I'm guessing that app1 is rejecting my cookie, and returning me to the
login page again, but why?

I must be missing something simple. Any ideas?



Relevant Pages

  • ODBC Connection
    ... I got problem with ODBC connection, I have a product server and a stage ... Dim intTemp As Integer ... and create a instance of login from asp page, ...
    (microsoft.public.sqlserver.odbc)
  • Custom login will not work
    ... When I started a new ASP project I was eager to use the login facilities ... Dim authTicket As FormsAuthenticationTicket ... Dim cookieName As String = FormsAuthentication.FormsCookieName ... PersonID = CType, Integer) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Application run correctly in a server with Visual Studio but not run in web server
    ... server with .NET framework and without Visual Studio. ... Here is the code of Login() in VB.NET: ... Dim lEstado As Boolean ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Login help
    ... the user login name from the system all i want is to record them using the ... Private Sub Command2_Click ... Dim strUIdCheck As Variant ... Dim strErrorMessage As String ...
    (microsoft.public.access.devtoolkits)
  • RE: Login help
    ... the user login name from the system all i want is to record them using the ... Private Sub Command2_Click ... Dim strUIdCheck As Variant ... Dim strErrorMessage As String ...
    (microsoft.public.access.devtoolkits)