locked
login control RRS feed

  • Question

  • User887623398 posted

    Hello

    I've defined user name and password for admin in web.cofig :

    <system.web>
          <authentication mode="Forms">
            <forms name="SavingsPlan" defaultUrl="admin.aspx" loginUrl="Login.aspx" >
              <credentials passwordFormat="SHA1">
                <user name="admin"
                      password="7712757"/>
                
              </credentials>
            
            </forms>
            
          </authentication>
       
       <authorization>
         <allow users="*"/>
         <deny users="?"/>
       </authorization>
    
     </system.web>
      
        
      <location path="Admin.aspx">
            <system.web>
    <authorization>

    <allow roles="Administrator"/>
    <deny users="*"/>
    </authorization>
    </system.web>
    </location>

    and place a login control on the my admin page:

    
    
    
    
    public partial class login : System.Web.UI.Page
    {
        
        protected bool authenthicate(String name,String password)
        {
            if(name == "admin")
               
            {
                if (password == "7712757")
                
                    return true;
                
            }
            return false;
        }
       public void onLogin(String name,String password)
        {
           if(authenthicate(name,password))
           {
               FormsAuthentication.RedirectFromLoginPage( );
    
           }
           else
           {
               Response.Write("Invalid user name or password");
           }
        }   
          
        
    }

    but it isn't working.

    Can you please inform me where is wrong in my code?

    thanks

    Saeed

    Monday, March 5, 2018 7:18 PM

All replies