Forms authentication not working???

Discussion in 'ASP .Net Security' started by Paul K, Nov 20, 2003.

  1. Paul K

    Paul K Guest

    I'm having a problem getting forms authentication to work.

    I have two web config files. The first one (located in
    the application directory) is defined as follows:

    <configuration>
    <system.web>
    <authentication mode="Forms">
    <forms loginUrl="default.aspx"/>
    </authentication>
    </system.web>
    </configuration>

    The second one (located in a subdirectory
    named "private") is defined as follows:

    <configuration>
    <system.web>
    <authorization>
    <deny users="?"/>
    </authorization>
    </system.web>
    </configuration>

    My authentication code follows:

    if (!mBLL.AuthenticateUser(txtUID.Text, txtPassword.Text,
    ref dt))
    {
    lblError.Text = "The provided credentials could
    not be authenticated. Please try again.";
    }
    else
    {
    Session.Contents.Add("UID",(object)txtUID.Text);
    Session.Contents.Add("EName",(object)(dt.Rows[0]
    ["FName"].ToString() + " " + dt.Rows[0]["LName"].ToString
    ()));
    Session.Contents.Add("EKey",dt.Rows[0]
    ["EmployeeKey"]);
    Session.Contents.Add("IsAdmin",dt.Rows[0]
    ["IsAdmin"]);
    Session.Contents.Add("WeekEnding",null);
    Session.Contents.Add("SelDate",null);

    url = FormsAuthentication.GetRedirectUrl
    (txtUID.Text,true);

    if (url == "/EPES/default.aspx")
    url = "private/production.aspx?MOVEWEEK=NONE";

    Response.Redirect(url);

    Whenever I try to access production.aspx directly, I am
    not redirected to default.aspx.

    If I test the result of the User.Identity.IsAuthenticated
    property on production.aspx, it is true (even without
    being authenticated).

    Any help would be greatly appreciated!

    Paul K
     
    Paul K, Nov 20, 2003
    #1
    1. Advertising

  2. Paul K

    Paul K Guest

    Found my problem

    Stupid cookie... :)
     
    Paul K, Nov 20, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    2
    Views:
    1,528
    Tommy
    Feb 13, 2004
  2. Russell
    Replies:
    6
    Views:
    609
    russell mccloy
    Mar 24, 2005
  3. =?Utf-8?B?S3VsZGVlcA==?=

    Logout not working - Forms Authentication domain wide cookie

    =?Utf-8?B?S3VsZGVlcA==?=, Jun 13, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    644
    =?Utf-8?B?S3VsZGVlcA==?=
    Jun 13, 2005
  4. Matt
    Replies:
    2
    Views:
    568
  5. Eric
    Replies:
    2
    Views:
    596
Loading...

Share This Page