1

我使用 ASP.NET 会员提供程序在我的本地计算机上设置了此会员站点。当我去:

http://localhost/admin/

它把我重定向到

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>
4

1 回答 1

5

你能给我们看一些代码吗?如果你使用FormsAuthentication.RedirectFromLoginPage方法,你应该得到你想要的。你FormsAuthentication.SetAuthCookie改用了吗?

更新

更改为path="/Admin"_web.configpath=/

它不起作用的原因是您的身份验证 cookie 仅设置在/Admin路径中,并且您的浏览器将 URL 视为区分大小写,因此它不会将身份验证 cookie 发送回/admin/Default.aspx页面(小写admin)。

于 2009-05-19T16:52:15.463 回答