IIS 中的默认文档功能已关闭,情况如下...
我的项目的起始页是 A.aspx。我运行该项目,果然,A.aspx 出现在浏览器的 url 中。不过,A.aspx 发现没有用户登录,并像应该的那样重定向到 Login.aspx。
A.aspx:
if (Session["UserStuff"] == null)
Response.Redirect("~/Account/Login.aspx");
login.aspx 显示,但当用户登录时,代码:
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true);
始终重定向到“Default.aspx”而不是“A.aspx”
我检查了 FormsAuthentication.GetRedirectUrl ,果然它返回“Default.aspx”
我被难住了???
最佳答案
在 web.config
中,您可以 set the default page使用 defaultUrl
属性:
<authentication mode="Forms">
<forms
loginUrl="login.aspx"
defaultUrl="a.aspx"
protection="All"
timeout="30"
/>
</authentication>
关于asp.net表单例份验证重定向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3483189/