title: Prevent IIS7/ASP.NET locking directory with images
body: <p>I have an ASP.NET webapp using the ASP.NET MVC 2 framework. It allows users to upload files to an uploads folder. The issue occurs when an image within a sub-folder is accessed by a web browser:</p>
  
  <blockquote>
    <p><a href="http://mywebapp/uploads/image_gallery/sub_folder/image.jpg" rel="nofollow">http://mywebapp/uploads/image_gallery/sub_folder/image.jpg</a></p>
  </blockquote>
  
  <p>The uploads folder is static and can't be modified by users, but anything below it is intended to be modifiable.</p>
  
  <p>In the above example, the image_gallery folder becomes locked because w3wp.exe appears to create a handle on the sub_folder directory (using process explorer by sysinternals). I am still able to rename the sub_folder directory and the handle seems to stay with it after a rename, but i can't rename the parent folder (image_gallery in this case).</p>
  
  <p>I can still browse within the folder and view other images and files etc. But can't rename the parent folder.</p>
  
  <p>As this is using the MVC 2 framework i've put in an exclusion for the uploads folder like so:</p>
  
  <pre><code>routes.IgnoreRoute("upload/{*pathInfo}");
  </code></pre>
  
  <p>into global.asax, so i'm assuming that ASP.NET is serving up those images directly (outside of the MVC framework)</p>
  
  <p>So I guess my question is, is there any way to prevent IIS from putting a handle on specific directories or forcing it to remove a handle? Is the MVC 2 framework doing something tricky even though i have the ignoreroute specified?</p>
  
  <p>Thanks in advance for any tips!</p>