views:

528

answers:

1

I have this membership site setup on my local machine using the ASP.NET membership provider. When I go to:

http://localhost/admin/

It redirects me to

http://localhost/Login.aspx?ReturnUrl=%2fadmin%2fDefault.aspx

Which is fine. But after I put in my login information, the page just seems to refresh. It doesn't actually log me in, and it just looks like it refreshes the page. If I change the URL to:

http://localhost/Login.aspx

It works fine. It logs me in no problem, and redirects me to my default page. I also checked the live site and it does the same thing. Any ideas? Thanks in advance!

EDIT: Here is the markup:

<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 setup:

<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>
+3  A: 

Can you show us some code? If you are using FormsAuthentication.RedirectFromLoginPage method, you should get what you want. Are you using FormsAuthentication.SetAuthCookie instead?

Update

Change path="/Admin" in web.config to path=/

The reason it doesn't work is that your authentication cookie is only set in /Admin path and your browser treats URLs as case sensitive so it won't send the authentication cookie back to the /admin/Default.aspx page (lowercase admin).

Mehrdad Afshari
I added the code to the post. Any thoughts?
SkippyFire
@SkippyFire: updated the answer..
Mehrdad Afshari
I just tried moving my login page inside the admin directory, and changing the loginURL to "/Admin/Login.aspx", and I still see the same problem.
SkippyFire
Actually, the login works, but it doesn't actually redirect me to the page...
SkippyFire
@SkippyFire: On second thought, I saw that you said `/Login.aspx` works so that reason couldn't be true. Try navigating to `/Admin/Default.aspx` (uppercase Admin) to see if it works.
Mehrdad Afshari
Wow, you're a freakin' genius! That worked like a charm. I owe you man!
SkippyFire
You're welcome ;)
Mehrdad Afshari
@Mehrdad - why would it be case-sensitive?
Jose Basilio
URLs *are* case sensitive. This is a Windows-style living that makes us think they are not. On UNIX servers, this causes plenty of issues with links and image URLs on plain HTML Web sites. Just the domain name part (which is resolved by the DNS server) is case-insensitive.
Mehrdad Afshari