FormsAuthentication redirecting to login page when visiting root of website

Posted by Ryan Lattimer on Stack Overflow See other posts from Stack Overflow or by Ryan Lattimer
Published on 2010-01-27T22:05:28Z Indexed on 2010/05/15 23:20 UTC
Read the original article Hit count: 325

I wanted to use FormsAuthentication to secure my static files as well on my site, so I followed the instructions located here http://learn.iis.net/page.aspx/244/how-to-take-advantage-of-the-iis7-integrated-pipeline/ under title "Enabling Forms Authentication for the Entire Application".

Now though, when I try to visit the site by going directly to http://www.mysite.com I get redirected to http://www.mysite.com/Login.aspx?ReturnUrl=%2f instead of it using my DefaultDocument I have set. I can go to my default document by just visiting http://www.mysite.com/Home.aspx without any issues because it is set to allow anonymous access.

Is there something I need to add into my web.config file to make iis7 allow anonymous access to the root? I tried adding with anonymous access but no such luck.

Any help would be much appreciated.


Both Home and the Login form allow anonymous.

<location path="Home.aspx">
 <system.web>
  <authorization>
    <allow users="*" />
  </authorization>
 </system.web>
</location>
<location path="Login.aspx">
 <system.web>
  <authorization>
    <allow users="*" />
  </authorization>
 </system.web>
</location>

Login form is set as the loginUrl

<authentication mode="Forms">
  <forms protection="All" loginUrl="Login.aspx">
  </forms>
</authentication>

Default document is set as Home.aspx

<defaultDocument>
  <files>
    <add value="Home.aspx" />
  </files>
</defaultDocument>

I have not removed any of the iis7 default documents. However, Home.aspx is first in the priority.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about forms-authentication