Why repeating login

Discussion in 'ASP .Net Security' started by ad, Aug 30, 2006.

  1. ad

    ad Guest

    I use login controls in my web application, and have web.config as below:
    <forms name="HealthCookie" loginUrl="Login.aspx" defaultUrl="Home.aspx"
    protection="Validation" >
    If the user enter wrong password in the login control, the failureText of
    login control will appear.

    When I deploy my web application to another machine, and the use enter the
    correct password(the failureText does not appear), it login successful(the
    failureText did not appear), but it did not deirect to Home.aspx, the
    Login.aspx appear again.

    What is wrong ? why repeating login?
    below is my web.config and custum MembershipProvider
    Please help me.






    ----------------------------------------------------------------------------------------------------------------
    <?xml version="1.0"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <appSettings>
    </appSettings>
    <connectionStrings>
    ......................
    </connectionStrings>
    <system.web>
    <httpRuntime maxRequestLength="2097151"/>
    <membership defaultProvider="MyMembershipProvider">
    <providers>
    <add name="MyMembershipProvider" type="MyMembershipProvider"
    minRequiredPasswordLength="7"/>
    </providers>
    </membership>
    <httpHandlers>
    ....
    </httpHandlers>
    <siteMap>
    <providers>
    ......
    </providers>
    </siteMap>
    <authentication mode="Forms">
    <forms name="HealthCookie" loginUrl="Login.aspx" defaultUrl="Home.aspx"
    protection="Validation">
    </forms>
    </authentication>
    <authorization>
    <deny users="?"/>
    </authorization>
    <customErrors mode="RemoteOnly"
    defaultRedirect="~/ErrorPage/GenericErrorPage.aspx">
    .......
    </customErrors>
    <pages maintainScrollPositionOnPostBack="true"
    masterPageFile="~/MasterPage.master"/>
    <sessionState mode="InProc"/>
    <compilation debug="true">
    <buildProviders>
    .......
    </buildProviders>
    <assemblies>
    ......
    </system.web>
    </configuration>


    public class MyMembershipProvider : MembershipProvider
    {
    private FormsAuthenticationUserCollection _users = null;
    private FormsAuthPasswordFormat _passwordFormat;
    //private int _MinRequiredNonAlphanumericCharacters = 0;
    private int _MinRequiredPasswordLength = 4;
    //private int _MaxInvalidPasswordAttempts = 5;
    //private int _PasswordAttemptWindow = 5;


    #region Not Implemented Members
    public override string ApplicationName
    {
    .............................

    public override MembershipUser GetUser(string username, bool
    userIsOnline)
    {
    DateTime myDate = DateTime.Today;
    MembershipUser user = new MembershipUser(
    Name, // Provider name
    username, // Username
    null, // providerUserKey
    "", // Email
    String.Empty, // passwordQuestion
    "Comment", // Comment
    true, // isApproved
    false, // isLockedOut
    DateTime.Now, // creationDate
    DateTime.Now, // lastLoginDate
    DateTime.Now, // lastActivityDate
    DateTime.Now, // lastPasswordChangedDate
    new DateTime(1980, 1, 1) // lastLockoutDate
    );
    return user;

    }


    public override bool ChangePassword(string username, string
    oldPassword, string newPassword)
    {
    .............................................
    }


    public override void Initialize(string name,
    System.Collections.Specialized.NameValueCollection config)
    {
    base.Initialize(name, config);
    _passwordFormat = getPasswordFormat();
    string sMin=config["minRequiredPasswordLength"].ToString();
    sMin = WillNs.Util.GetDefault(sMin, "4");
    _MinRequiredPasswordLength = int.Parse(sMin);
    }

    public override bool ValidateUser(string username, string password)
    {
    bool Authenticated = false;
    Authenticated = DMHealth.CheckPW(username, password);
    if (Authenticated)
    {
    //HttpContext.Current.Session.Abandon();
    new AuthenticationSuccessEvent(username, this).Raise();
    return true;
    }
    else
    {
    new AuthenticationFailureEvent(username, this).Raise();
    return false;
    }
    }

    protected FormsAuthenticationUserCollection getUsers()
    {
    if (_users == null)
    {
    AuthenticationSection section = getAuthenticationSection();
    FormsAuthenticationCredentials creds =
    section.Forms.Credentials;
    _users = section.Forms.Credentials.Users;
    }

    return _users;
    }

    protected AuthenticationSection getAuthenticationSection()
    {
    Configuration config =
    WebConfigurationManager.OpenWebConfiguration("~");
    return
    (AuthenticationSection)config.GetSection("system.web/authentication");
    }

    protected FormsAuthPasswordFormat getPasswordFormat()
    {
    return
    getAuthenticationSection().Forms.Credentials.PasswordFormat;
    }
    protected MembershipSection getMembershipSection()
    {
    Configuration config =
    WebConfigurationManager.OpenWebConfiguration("~");
    return
    (MembershipSection)config.GetSection("system.web/Membership");
    }
    }
     
    ad, Aug 30, 2006
    #1
    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. Lewis

    datalist repeating first record

    Lewis, Aug 22, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    1,957
    Ignacio Machin
    Aug 22, 2003
  2. Lynn

    Datalist not repeating...why?`

    Lynn, Aug 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    666
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    903
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,966
    Smokey Grindel
    Dec 2, 2006
  5. Lynn

    Datalist not repeating...why?

    Lynn, Aug 16, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    273
Loading...

Share This Page