Can login with Login Control

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

  1. ad

    ad Guest

    I used login Controls of VS2005 to develop Web application.
    My program will check password and user ID in login.aspx. If the password
    is wrong, my program will display an "password is wrong" message to user.
    If the ID and password are correct, my program wiill transfer to home.aspx


    After my program deployment to server, when user login with correct ID and
    wrong pw, it display "password is wrong" message.
    But if the ID and password are both correct, it stay in login.aspx with no
    "password is wrong" message, but not transfer to home.aspx.

    It may be something wrong ! How can I do?
     
    ad, Aug 28, 2006
    #1
    1. Advertising

  2. ad

    Tim_Mac Guest

    hi ad,
    how can we know what's wrong when you didn't post any code?!
    please post your web.config and all the code-behind for your login page.

    tim
     
    Tim_Mac, Aug 28, 2006
    #2
    1. Advertising

  3. ad

    ad Guest

    Thanks, 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");
    }
    }





    "Tim_Mac" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > hi ad,
    > how can we know what's wrong when you didn't post any code?!
    > please post your web.config and all the code-behind for your login page.
    >
    > tim
    >
     
    ad, Aug 28, 2006
    #3
  4. ad

    Tim_Mac Guest

    hi Ad,
    i notice you have ~/home.aspx as your defaultUrl.
    how is your web site deployed in IIS. as a web site? virtual directory?
    or just in a folder?
    the reason i ask is because the ~ syntax refers to the root of the web
    application. if you have it deployed inside a folder without creating an
    application in IIS, the ~ url you use would refer to the wrong page and
    possibly a 404.

    tim
     
    Tim_Mac, Aug 29, 2006
    #4
  5. ad

    ad Guest

    Thanks,
    i deployed my project to as an application of IIS.
    But maybe the ~/ is not need.
    Have there any reason cause repeating login?




    "Tim_Mac" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > hi Ad,
    > i notice you have ~/home.aspx as your defaultUrl.
    > how is your web site deployed in IIS. as a web site? virtual directory?
    > or just in a folder?
    > the reason i ask is because the ~ syntax refers to the root of the web
    > application. if you have it deployed inside a folder without creating an
    > application in IIS, the ~ url you use would refer to the wrong page and
    > possibly a 404.
    >
    > tim
    >
     
    ad, Aug 29, 2006
    #5
  6. ad

    Tim_Mac Guest

    hi Ad,
    sorry i'm not sure what you mean by repeating login..
    tim
     
    Tim_Mac, Aug 29, 2006
    #6
  7. ad

    ad Guest

    I have remove the ~\ form the defaultUrl, but the user still repeating
    login.
    That is the login page appear again after the user login sucessfully, the
    web application dose not direct to defaultUrl


    "Tim_Mac" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > hi Ad,
    > sorry i'm not sure what you mean by repeating login..
    > tim
    >
     
    ad, Aug 30, 2006
    #7
  8. ad

    Tim_Mac Guest

    hi ad ,
    you could try adding an event handler for the OnLoggedIn event of your Login
    control.
    then you can use Response.Redirect to go wherever.

    hope this helps
    tim


    "ad" <> wrote in message
    news:...
    >I have remove the ~\ form the defaultUrl, but the user still repeating
    >login.
    > That is the login page appear again after the user login sucessfully, the
    > web application dose not direct to defaultUrl
    >
    >
    > "Tim_Mac" <>
    > ¼¶¼g©ó¶l¥ó·s»D:...
    >> hi Ad,
    >> sorry i'm not sure what you mean by repeating login..
    >> tim
    >>

    >
    >
     
    Tim_Mac, Aug 30, 2006
    #8
  9. ad

    ad Guest

    Hi, Tim
    Today I find a regularity on the problem pc.
    If I use http://health/HealthWeb (where health is computer name, HealthWeb
    is application name), the repeating login occur, but if I use
    http://127.0.0.1/HealthWeb or http://192.168.0.12/HealthWeb, it run ok.
    But if I call http://health/HealthWeb from another machine, it run ok.

    It's really something strange!

    Have some advice?


    "Tim_Mac" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > hi ad ,
    > you could try adding an event handler for the OnLoggedIn event of your
    > Login control.
    > then you can use Response.Redirect to go wherever.
    >
    > hope this helps
    > tim
    >
    >
    > "ad" <> wrote in message
    > news:...
    >>I have remove the ~\ form the defaultUrl, but the user still repeating
    >>login.
    >> That is the login page appear again after the user login sucessfully, the
    >> web application dose not direct to defaultUrl
    >>
    >>
    >> "Tim_Mac" <> ¼¶¼g©ó¶l¥ó·s»D:...
    >>> hi Ad,
    >>> sorry i'm not sure what you mean by repeating login..
    >>> tim
    >>>

    >>
    >>

    >
    >
     
    ad, Aug 31, 2006
    #9
  10. ad

    Tim_Mac Guest

    hi,
    you could try resetting the browser settings on that PC. it could be caused
    by a different security zone for the 'health' web site. i can't imagine
    exactly what would prevent the page loading, but perhaps cookies are
    disabled or something.

    all i can suggest is my previous post to manually redirect the user to
    whatever page you want them to, if it is still causing problems.

    good luck
    tim

    "ad" <> wrote in message
    news:...
    > Hi, Tim
    > Today I find a regularity on the problem pc.
    > If I use http://health/HealthWeb (where health is computer name,
    > HealthWeb is application name), the repeating login occur, but if I use
    > http://127.0.0.1/HealthWeb or http://192.168.0.12/HealthWeb, it run ok.
    > But if I call http://health/HealthWeb from another machine, it run ok.
    >
    > It's really something strange!
    >
    > Have some advice?
    >
    >
    > "Tim_Mac" <>
    > ¼¶¼g©ó¶l¥ó·s»D:...
    >> hi ad ,
    >> you could try adding an event handler for the OnLoggedIn event of your
    >> Login control.
    >> then you can use Response.Redirect to go wherever.
    >>
    >> hope this helps
    >> tim
    >>
    >>
    >> "ad" <> wrote in message
    >> news:...
    >>>I have remove the ~\ form the defaultUrl, but the user still repeating
    >>>login.
    >>> That is the login page appear again after the user login sucessfully,
    >>> the web application dose not direct to defaultUrl
    >>>
    >>>
    >>> "Tim_Mac" <>
    >>> ¼¶¼g©ó¶l¥ó·s»D:...
    >>>> hi Ad,
    >>>> sorry i'm not sure what you mean by repeating login..
    >>>> tim
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Tim_Mac, Aug 31, 2006
    #10
    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. ike2010
    Replies:
    0
    Views:
    696
    ike2010
    Nov 15, 2005
  2. =?Utf-8?B?d2Vp?=

    Login control with RadioBox control

    =?Utf-8?B?d2Vp?=, Feb 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    400
    =?Utf-8?B?d2Vp?=
    Feb 28, 2006
  3. Sasquatch
    Replies:
    2
    Views:
    1,366
    Sasquatch
    Oct 3, 2006
  4. Sasquatch
    Replies:
    2
    Views:
    508
    Sasquatch
    Oct 4, 2006
  5. Jack
    Replies:
    1
    Views:
    815
Loading...

Share This Page