locked
problem with login name and login status RRS feed

  • Question

  • User-908650885 posted

    Hi friends,

    I have a login name and a login status control in default.aspx,im using asp.net membership,(not custom)

    login name does not show user name and login status also

    before and after login, login status shows 'login' text.

    here is details:

    web.config:

    <configuration>
      <connectionStrings>
        <add name="LoginConnectionString"
             connectionString="Data Source=.;Initial Catalog=dblogin;Integrated Security=True" />
      </connectionStrings>
        <system.web>
          <authentication mode="Forms"/>
          
          <membership defaultProvider="MyMembershipProvider">
            <providers>
              <add name="MyMembershipProvider"
                   type="System.Web.Security.SqlMembershipProvider"
                   passwordFormat="Clear"
                   minRequiredPasswordLength="1"
                   minRequiredNonalphanumericCharacters="0"
                   requiresQuestionAndAnswer="false"
                   connectionStringName="LoginConnectionString"/>
            </providers>
          </membership>
    
          <compilation debug="true" targetFramework="4.0" />
        </system.web>
    
      
    </configuration>

    default.aspx:

    <asp:LoginName ID="LoginName1" FormatString="welcome {0}" runat="server" />
    <asp:LoginStatus ID="LoginStatus1" runat="server" />

    default.aspx.cs

    protected void LoginStatus1_Logout(object sender, LoginCancelEventArgs e)
        {
            FormsAuthentication.SignOut();
            Response.Redirect("Default.aspx");
        }

    login.aspx.cs:

    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            e.Authenticated = true;
            FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false);
        }

    that's all. what I have to do more?

    Sunday, June 8, 2014 11:11 AM

Answers

  • User-908650885 posted

    I changed these lines and it worked:

    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            if (Membership.ValidateUser(Login1.UserName, Login1.Password))
            {
                e.Authenticated = true;
                FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false);
            }
        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 2:28 PM