首页 新闻 会员 周边

asp.net登陆后总是被重新定位到登陆界面

0
悬赏园豆:20 [已解决问题] 解决于 2011-08-16 17:42

我的asp.net网站没有用Session来判断很重定向(觉得麻烦),用的是forms认证,但是总是登陆正确也被重定位到登陆界面:Admin文件夹下web.config代码为:

<configuration>
    <appSettings/>
    <connectionStrings/>
 
    <system.web>
      <authorization>
        <deny users ="*"/>
        <allow users ="admin" verbs ="*"/>
      </authorization>
    </system.web>
</configuration>

Login.aspx的后台代码为:

protected void btnLogIn_Click(object sender, EventArgs e)
    {
        string UserName = txtUserName.Text.ToString().Trim();
        string PassWord = txtPassWord.Text.ToString().Trim();
        //验证码
        AccountEntity user = new AccountEntity();
        user.Username = UserName;
        user.Password = PassWord;
        user = new Account().Login(user );
        if (user != null)
        {
            //是否有必要在此创建会话呢?
            FormsAuthentication.RedirectFromLoginPage(UserName ,false  );
            Response.Redirect("Main.aspx");
        }
        else
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "Message", "alert('用户名或密码错误!')",true);
            return;
        }
    }

其它页面没有控制重定位页面。我知道问题很菜,但仍然希望友友们能够花那么一丁点时间帮助我一下,非常感谢O(∩_∩)O~!

问题补充:

根目录下web.config部分为:    

<authentication mode ="Forms">
        <forms loginUrl="Admin/Login.aspx" path="/" name=".ASPXAUTH"></forms>
      </authentication>

水又仁的主页 水又仁 | 初学一级 | 园豆:180
提问于:2011-08-15 17:43
< >
分享
最佳答案
0

貌似没看到你在什么地方标记“我已经登录成功了”

收获园豆:20
顾晓北 | 专家六级 |园豆:10844 | 2011-08-15 17:59
那该如何标记?用cookie等如何用呢?谢谢
水又仁 | 园豆:180 (初学一级) | 2011-08-15 18:59
你既然是用微软封装的那一套,那你多看看吧,里面有一个标记用户已经验证过的属性,招招看。
顾晓北 | 园豆:10844 (专家六级) | 2011-08-15 23:09
o,已经解决了,是因为 的错误。OK,thanks!
水又仁 | 园豆:180 (初学一级) | 2011-08-16 17:41
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册