我必须使用ASP.NET成员资格提供我的本地机器上的这个会员网站设置。当我去:

HTTP://本地主机/管理/

它重定向我

HTTP://localhost/Login.aspx RETURNURL =%2fadmin%2fDefault的.aspx

这很好。但是,我把我的登录信息后,页面似乎只是刷新。它实际上并没有记录我的,它只是看起来像它刷新页面。如果更改的URL为:

HTTP://localhost/Login.aspx

它工作正常。它记录了我没有问题,我重定向到我的默认页。我还检查了现场的网站,它做同样的事情。有任何想法吗?由于事先!

编辑:这里是标记:

<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.configpath=/

它不工作的原因是,你的身份验证cookie在/Admin路径只设置你的浏览器将网址作为区分大小写的,所以它不会发送身份验证cookie回/admin/Default.aspx页面(小写admin)。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top