views:

137

answers:

4

I have a web application project and I have put my source code in a folder called "source". Now when I run the application I am able to see contents of "source" folder (it lists the code files) by appending the folder name to the url "/source" in IE.

How do I prevent this?

A: 

It sounds like you have directory browsing on....

Tell IIS not to allow directory browsing by unchecking it under the virtual directory tab for the application in IIS.

klabranche
A: 

If this is IIS you can turn off directory browsing. Open the IIS manager and navigate to your application root. Expand the application root and right-click on the Source directory and choose Properties. In the Directory tab ensure that the Directory Browsing checkbox is left unchecked.

Hope this helps.

psuphish05
A: 

Don't put your code online would be the obvious answer.

But you could restrict access with the web.config

<location path="Source">
 <system.web>
  <authorization>
   <deny users="*"/>
   <deny roles="*"/>
  </authorization>
 </system.web>
</location>
Chad
+4  A: 

The easiest, and most fool-proof, answer would be to put the source-code folder outside of the web root:

-var-+-www-+- htdocs
        |      |
        |      +- images
        |      |
        |      +- javascript
        |      |
        |      +- css
        |      |
        |      +- ...and so on...
        |
        +- source code
        |
        +- php includes
        |
        +- ...and so on...

The idea is that only the htdocs directory, and sub-directories, should be visible/accessible to web-browsers; the other directories should not be accessible at all, except via ftp (or the administration interface provided by your web host).

David Thomas
+1 The technique of including files in your code that are out of the wwwroot or htdocs folder is the most simple and effective way to hide your code.
backslash17