title: Restricting access to pages but not to start page in ASP.NET MVC
body: <p>I'm building an ASP.NET MVC web application and I'm trying to restrict access to pages.</p>
  
  <p>I've specified that I want to use forms authentication in my Web.config:</p>
  
  <pre><code>&lt;system.web&gt;
      ...
      &lt;authentication mode="Forms"&gt;
          &lt;forms loginUrl="~/login" timeout="20" protection="All" /&gt;
      &lt;/authentication&gt;
      &lt;authorization&gt;
          &lt;deny users="?" /&gt;
      &lt;/authorization&gt;
      ...
  &lt;/system.web&gt;
  </code></pre>
  
  <p>This will deny access to all pages, but I want to make some pages public. I can do this in Web.config as well:</p>
  
  <pre><code>&lt;location path="about-us"&gt;
      &lt;system.web&gt;
          &lt;authorization&gt;
              &lt;allow users="*" /&gt;
          &lt;/authorization&gt;
      &lt;/system.web&gt;
  &lt;/location&gt;
  &lt;location path="contact-us"&gt;
      &lt;system.web&gt;
          &lt;authorization&gt;
              &lt;allow users="*" /&gt;
          &lt;/authorization&gt;
      &lt;/system.web&gt;
  &lt;/location&gt;
  …
  </code></pre>
  
  <p>This works all fine. The problem is the start page, more precisely when the user goes to "<a href="http://www.mydomain.com/" rel="nofollow">http://www.mydomain.com/</a>", with no further path specified. How can I specify that this page should be public?</p>
  
  <p>I've tried some variations, but nothings seems to work. I always get an error:</p>
  
  <p><strong>No path</strong></p>
  
  <pre><code>&lt;location&gt;
      &lt;system.web&gt;
          &lt;authorization&gt;
              &lt;allow users="*" /&gt;
          &lt;/authorization&gt;
      &lt;/system.web&gt;
  &lt;/location&gt;
  </code></pre>
  
  <p><strong>Empty path</strong></p>
  
  <pre><code>&lt;location path=""&gt;
      &lt;system.web&gt;
          &lt;authorization&gt;
              &lt;allow users="*" /&gt;
          &lt;/authorization&gt;
      &lt;/system.web&gt;
  &lt;/location&gt;
  </code></pre>
  
  <p><strong>Dot</strong></p>
  
  <pre><code>&lt;location path="."&gt;
      &lt;system.web&gt;
          &lt;authorization&gt;
              &lt;allow users="*" /&gt;
          &lt;/authorization&gt;
      &lt;/system.web&gt;
  &lt;/location&gt;
  </code></pre>
  
  <p><strong>Slash</strong></p>
  
  <pre><code>&lt;location path="/"&gt;
      &lt;system.web&gt;
          &lt;authorization&gt;
              &lt;allow users="*" /&gt;
          &lt;/authorization&gt;
      &lt;/system.web&gt;
  &lt;/location&gt;
  </code></pre>
  
  <p>Any suggestions?</p>