Knowledge Essentials - 3Essentials Hosting

Where does ASP.Net search for web.config file?

Article ID: 240

 Back to Search

When IIS (Internet Information Server, the Microsoft webserver solution) executes ASP.NET pages, it will look for a web.config file in one of two locations:

  • the application root
  • a bin directory under the application root

So... what is the application root?  Well, the httpdocs folder, as your website's "root" is by default an application root.  Also, any other directory you specify as an "application" within IIS will also be an application root.  You can do this via Plesk's WebDirectory/VirtualDirectory functions.  The following scenarios explain the impact of a directory being an "application" versus not being "an application" within IIS:

scenario a) httpdocs <===> website root, an IIS application... located at www.yourdomain.com
- run a asp.net file here (httpdocs\myfile.aspx), and IIS looks for a web.config in the application root (httpdocs) or a bin directory off of it (httpdocs\bin).

scenario b) httpdocs\somefolder ... simply a folder located inside the application at www.yourdomain.com
- run a asp.net file here (httpdocs\somefolder\myfile.aspx), and IIS looks for a web.config in the application root (httpdocs) or a bin off of it (httpdocs\bin).

scenario c) httpdocs\someotherfolder, where we've "created an application" at "someotherfolder". That means "someotherfolder" is now the "application root" for files that are executed in it. 
- run a asp.net file here (httpdocs\someotherfolder\myfile.aspx) and IIS looks for a web.config file in the application root (httpdocs\someotherfolder) or a bin off of it (httpdocs\someotherfolder\bin).

So, where you "create the application" will affect where IIS view the location of the application, and it's related web.config (and potentially other config files or assemblies).   This is how you can run unique ASP.net configurations under the same site... for example:

httpdocs\someotherfolder as an application has it's own web.config.
httpdocs\yetanotherfolder as an application would likewise have it's own web.config.

For details on how to set a folder as an "an application" (an IIS application), see the following KB article:  Setting folder as IIS Application

 
Downloads Associated With This Article
No downloads are currently associated with this article.