为什么我的代码不起作用? [英] Why my code isn't working?

查看:81
本文介绍了为什么我的代码不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在web.cofig中定义了admin的用户名和密码。

并在我的管理页面上放置一个登录控件。

但它不是工作。



你能告诉我我的代码出了什么问题吗?



谢谢



我尝试过:



web.config:

I've defined user name and password for admin in web.cofig.
and place a login control on the my admin page.
but it isn't working.

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

thanks

What I have tried:

web.config:

<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>





登录控制:





login control:

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

推荐答案

<allow users="*"/>
   <deny users="?"/>





您使用的是上面但低于您的用户使用的用户(没有s)



you are using users above but below you use user(without an s)

<user name="admin"

               password="7712757"/>





这可能会导致一些问题..但你的问题太模糊了



That might cause some issues.. But your question is way too vague


这篇关于为什么我的代码不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆