Hi guys, is it possible to prevent browsing of a folder contents in an ASP.NET web application other than creating a default page, say using web.config? I would like to avoid using IIS for this if possible.
Thanks
Hi guys, is it possible to prevent browsing of a folder contents in an ASP.NET web application other than creating a default page, say using web.config? I would like to avoid using IIS for this if possible.
Thanks
If you are using IIS7, you can use web.config files for this. Specify a <location>
tag for the desired folder, and give it a <directoryBrowse>
sub-tag, ie:
<location path="path to your folder">
<system.webServer>
<directoryBrowse enabled="false" />
</system.webServer>
</location>
The previous answer system.webServer -> directoryBrowse is new and can be used when your site is running under IIS7 (be it debugging or otherwise) only, it will not work in IIS6. In IIS6 you need to do it using the IIS management console.