为什么我的asp.net会员登录页面不与重定向工作?
-
22-08-2019 - |
题
我必须使用ASP.NET成员资格提供我的本地机器上的这个会员网站设置。当我去:
它重定向我
HTTP://localhost/Login.aspx RETURNURL =%2fadmin%2fDefault的.aspx
这很好。但是,我把我的登录信息后,页面似乎只是刷新。它实际上并没有记录我的,它只是看起来像它刷新页面。如果更改的URL为:
它工作正常。它记录了我没有问题,我重定向到我的默认页。我还检查了现场的网站,它做同样的事情。有任何想法吗?由于事先!
编辑:这里是标记:
<asp:Login ID="Login1" runat="server" CssClass="LoginBox" TitleText="Please Log In">
<LayoutTemplate>
<h2>
Please Log In:</h2>
<p runat="server" id="FailureText" visible="false">
Either your email address or password was incorrect. Please try again.</p>
<strong>Email</strong><br />
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
Text="*"></asp:RequiredFieldValidator>
</p>
<p>
<strong>Password</strong><br />
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
Text="*"></asp:RequiredFieldValidator>
</p>
<p>
<asp:Button ID="Login" CommandName="Login" runat="server" Text="Log In" /></p>
<p>
Please <a runat="server" id="Link_ContactUs">contact </a>an administrator if you
are having trouble logging in or have forgotten your password.</p>
</LayoutTemplate>
</asp:Login>
的web.config设置:
<authentication mode="Forms">
<forms loginUrl="/Login.aspx"
protection="All"
timeout="60"
name="AppNameCookie"
path="/Admin"
requireSSL="false"
slidingExpiration="true"
defaultUrl="/Admin/Default.aspx"
cookieless="UseCookies"
enableCrossAppRedirects="false" />
</authentication>
解决方案
您能告诉我们一些代码?如果您正在使用FormsAuthentication.RedirectFromLoginPage
方法,你应该得到你想要的。您是否使用FormsAuthentication.SetAuthCookie
呢?
更新
在path="/Admin"
变化web.config
到path=/
它不工作的原因是,你的身份验证cookie在/Admin
路径只设置你的浏览器将网址作为区分大小写的,所以它不会发送身份验证cookie回/admin/Default.aspx
页面(小写admin
)。
不隶属于 StackOverflow