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>