title: Disable Directory Listing in IIS
body: <p>In my web application all the .aspx pages resides in Pages directory. The project structure is shown below:</p>
  
  <p><img src="https://i.stack.imgur.com/JiGVi.png" alt="enter image description here"></p>
  
  <p>The Home.aspx is set as Start Page and the Web.config file of the Pages folder contains:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;location path="Secured"&gt;
      &lt;system.web&gt;
      &lt;authorization&gt;     
          &lt;deny users="?"/&gt;
          &lt;allow users="*"/&gt;
      &lt;/authorization&gt;
      &lt;/system.web&gt;
  &lt;/location&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And the main Web.config has:</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
    &lt;forms loginUrl="~/Pages/Login.aspx" timeout="2880" defaultUrl="~/Pages/Secured/Home.aspx" /&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p>So when the application launches it redirects to the Login page with the URL:</p>
  
  <blockquote>
    <p><a href="http://localhost:2453/Pages/Login.aspx?ReturnUrl=%2fPages%2fSecured%2fHome.aspx" rel="noreferrer">http://localhost:2453/Pages/Login.aspx?ReturnUrl=%2fPages%2fSecured%2fHome.aspx</a></p>
  </blockquote>
  
  <p>Now if I delete the </p>
  
  <blockquote>
    <p>Login.aspx?ReturnUrl=%2fPages%2fSecured%2fHome.aspx</p>
  </blockquote>
  
  <p>from that URL and press enter it is taking me to the Directory Listing:</p>
  
  <p><img src="https://i.stack.imgur.com/9IoeZ.png" alt="enter image description here"></p>
  
  <p>What I want that it will again send me to the Login page located at </p>
  
  <blockquote>
    <p><a href="http://localhost:2453/Pages/Login.aspx" rel="noreferrer">http://localhost:2453/Pages/Login.aspx</a></p>
  </blockquote>
  
  <p>How can I achieve this? Your help be appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>The localhost:
  <img src="https://i.stack.imgur.com/oi237.png" alt="enter image description here"></p>