Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I could not find a way to configure IIS, but I did find a workaround using an asp.net generic handler (<a href="http://forums.asp.net/p/1478217/3453189.aspx" rel="nofollow">http://forums.asp.net/p/1478217/3453189.aspx</a>, scroll down to the answer by gvlahakis).</p> <p>First, create a generic handler that returns 404:</p> <pre><code>public class DirectoryBrowsingAttempt : IHttpHandler { public bool IsReusable {get {return true;} public void ProcessRequest(HttpContext context) {context.Response.StatusCode = 404;} } </code></pre> <p>Second, add tags to the web.config to point directory browsing attempts to the above handler, one for each folder that you need to protect, in both the httpHandlers and system.webServer sections. The tags below protect a folder named "js" off of the root. </p> <pre><code>&lt;httpHandlers&gt; &lt;add verb="*" path="js/*" validate="false" type="MyNameSpace.DirectoryBrowsingAttempt"/&gt; &lt;/httpHandlers&gt; &lt;system.webServer&gt; &lt;handlers&gt; &lt;add name="NoAccess" verb="*" path="js/*" preCondition="integratedMode" type="MyNameSpace.DirectoryBrowsingAttempt"/&gt; &lt;/handlers&gt; </code></pre> <p></p> <p>This workaround behaves differently in IIS 6 vs. IIS 7. For example, I protected a folder that contained the site's images in this manner: IIS 6 still delivered the images contained in this folder to web pages (the desired behavior, I just want to block directory browsing attempts); IIS 7 blocked them.</p> <p>There are probably ways to use the "location" tab in the web.config to allow images to be served up by overriding the default image handler, but I've no desire to go that far down the rabbit hole.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload