Forms验证无法重定向问题
lg868 2008-02-22 02:24:19 各位高手,代码如下所示:
<authorization>
<deny users="?"/>
</authorization>
<authentication mode="Forms">
<forms name=".ASPXAUTH " loginUrl="Login.aspx" defaultUrl="Default.aspx" timeout="30" path="/">
</forms>
</authentication>
程序代码如下:
CLogin clogin = new CLogin();
DataSet ds = new DataSet();
string Err = clogin.IsExist(this.UserLogin.UserName,this.UserLogin.Password,out ds);
if ("YES" == Err)
{
LoginInfo logininfo = new LoginInfo();
logininfo.UserID = Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"]);
logininfo.DeptID = Convert.ToInt32(ds.Tables[0].Rows[0]["DeptID"]);
logininfo.Name = ds.Tables[0].Rows[0]["Name"].ToString();
Session["UserInfo"] = logininfo;
#region //Forms验证添加票据,加密并保存Cookie
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, logininfo.Name, DateTime.Now,
DateTime.Now.AddMinutes(30), false, "LGStruct","/");
string HashTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie httpcookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket);
httpcookie.Secure = true;
Response.Cookies.Add(httpcookie);
#endregion
FormsAuthentication.SetAuthCookie(logininfo.Name, false);
Response.Redirect(FormsAuthentication.DefaultUrl);
}
else
{
Response.Write(@"<script>alert(非法操作<br>错误原因:" + Err + ")</script>");
}
验证都没错的,用户名密码都是正确的,执行到最后一句话,无法重定向到我设置在web.config中Forms的缺省页面,请问高手,是我少写了什么吗?