登陆验证

if (Session["CheckCode"].ToString().ToLower() == Str_verifycode)
            {
                Str_password = Maticsoft.DBUtility.DESEncrypt.Encrypt(Str_password);
                string sql = string.Format(@"select * from usermanager where userName=@userName and passWord=@passWord");
                SqlParameter[] para = new SqlParameter[] { 
                new SqlParameter("@userName",SqlDbType.VarChar,50),
                new SqlParameter("@passWord",SqlDbType.NVarChar,50)
                };
                
                para[0].Value = Str_username;
                para[1].Value = Str_password;
                DataSet ds = Maticsoft.DBUtility.DbHelperSQL.Query(sql, para);
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    Session["ID"] = ds.Tables[0].Rows[0]["ID"].ToString();
                    Session["UserName"] = ds.Tables[0].Rows[0]["userName"].ToString();

                    FormsAuthentication.RedirectFromLoginPage(Str_username, false);

                    Response.Redirect("AdminManager/index.html"); //定位到登陆后页面
                }



添加一个Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <!--授权 
此节设置应用程序的授权策略。可以允许或拒绝不同的用户或角色访问 
应用程序资源。通配符: "*" 表示任何人,"?" 表示匿名 
(未经身份验证的)用户。 
-->
    <authorization>
      <deny users="?"/>
    </authorization>
  </system.web>
</configuration>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值