请大家帮我看看这个Forms认证问题,谢谢。
Web应用程序虚拟目录为djmx,
djmx目录下的web.config文件有关内容为
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<location path="default.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<system.web>
...
...
<authentication mode="Forms">
<forms name=".ASPXAUTH " loginUrl="/default.aspx" protection="All" timeout="30"
path= "/djmx">
</forms>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
...
其中default.aspx是我做的验证窗体,在djmx下面
问题是:按理来说我没有登陆随便访问一个页面都会被重定向到localhost:8080/djmx/default.aspx
但是当我输入localhost:8080/djmx/test.aspx时浏览器显示的地址是http://localhost:8080/default.aspx?ReturnUrl=%2fdjmx%2ftest.aspx并显示http 4004错误
~~~~~~~~~这儿少了/djmx,这是为什么?
我的default.aspx的关键代码如下:(ValidateUser函数检查用户是否输入了正确的密码)
private void Submit1_ServerClick(object sender, System.EventArgs e)
{
if(ValidateUser(Text1.Value,Password1.Value))
{
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt=new FormsAuthenticationTicket(1,Text1.Value,DateTime.Now,DateTime.Now.AddMinutes(30),true,"your custom data"); //创建一个验证票据
cookiestr=FormsAuthentication.Encrypt(tkt);//并且加密票据
ck=new HttpCookie(FormsAuthentication.FormsCookieName,cookiestr);// 创建cookie
ck.Expires=tkt.Expiration;//设置cookie有效期
ck.Path=FormsAuthentication.FormsCookiePath;//cookie存放路径
Context.Response.Cookies.Add(ck);
string strRedirect;
strRedirect=null;
//strRedirect=Request["ReturnUrl"];
if(strRedirect==null)
{
if(Text1.Value=="administrator")
Context.Response.Redirect("test.aspx");
else
Context.Response.Redirect("gpdjxt.htm");
}
else Context.Response.Redirect(strRedirect,true);
}
else
{
Context.Response.Redirect("logonerror.htm");
}
}