登陆按钮的处理

asp.net应用程序首先碰到的是用户登录处理,按下登陆按钮时需要关闭本页面,打开一个没有地址栏菜单栏、工具栏的新窗口,我的处理方法如下(只能在IE下使用,这方法本人并不喜欢,可老板喜欢,局域网下使用,安全系数并不要很高,防君子就可以了,用户的个性菜单是存放在一个以用户ID命名的xml文件的)
 1    private void btOK_Click(object sender, System.EventArgs e)
 2        {
 3            string s ="<script language = JavaScript>";
 4            if (Page.IsValid) 
 5                   {
 6                string userId = tbUser.Text; //加密口令
 7                CryptMethod cr = new CryptMethod();
 8                string cryptpass = cr.Encrypto(tbPass.Text);
 9                bool success = Account.SignIn(userId,cryptpass); //判断用户名和口令
10                string filename = Server.MapPath(XML_FILE+userId+".xml");
11                if(!File.Exists(filename))  //判断用户配置文件
12                      {
13                
14                                    lbError.Text ="没有用户配置文件"
15                    return ;
16                   }

17                                
18                if (success) //口令正确
19                        {
20                    if (FormsAuthentication.GetRedirectUrl(userId, false).EndsWith(URL_DEFAULT)) 
21                    {
22                                  FormsAuthentication.SetAuthCookie(userId, false);
23                
24                                                s += "window.opener=null;" + System.Environment.NewLine;
25                        s += "window.close();" + System.Environment.NewLine;
26                        if (chkPassword.Checked)//进入修改口令界面
27                               {
28                                  s +="window.open('/PressMange/UserControl/UserChangePassPerson.aspx');"+System.Environment.NewLine;
29                           }

30                        else  //进入主界面
31                        s += "window.open('main.aspx','dialog','left=0,top=0,height=710,width=1010,resizable=1,status=0,scrollbars=0');"+System.Environment.NewLine;
32                       
33                    s+="</script>";
34
35                    RegisterClientScriptBlock("script",s);
36                
37                    }

38                    else
39                    {
40               
41                    FormsAuthentication.RedirectFromLoginPage(userId, false);
42                    }

43                  }

44                else 
45                {
46                    lbError.Text ="非法登陆";
47                }

48            }

49
50        }

posted on 2005-11-12 13:29  蔚然之家  阅读(893)  评论(0编辑  收藏  举报

导航