Changing ASP.net Temporary Files Folder

By Akbar

One of my client was having problems with the small space on the C drive on a server machine which was hosting a ASP.net application. There were few errors in the server error about “No enough space”.Though I would say that in ideal situation it would be best to increase the space on the C: drive as most of the other Operating System related applications also reply on the free space on C: drive, when there is no other easy way of increasing the space on C: drive, administrator can relocate the temporary files folder created by ASP.net.

Please note that ASP.net create a compile version of the site and stores it in its default temporary ASP.net folder. This is usually %Windows Install Folder%Microsoft.NETFrameworkv2.0.50727Temporary ASP.NET Files (For ASP.Net 2.0)This folder can grow very fast in case web server has large ASP.net sites hosted on that server. Fortunately, ASP.net provides a simple way to change this location. This is stored in the web.config file and can defined in the Global web.config (placed at %Windows Install Folder%Microsoft.NETFrameworkv2.0.50727CONFIG). To change this path add the new full folder path in the Compilation section of the configuration file. Here is a sample of how this looks like (this must be under System.Web section):

<compilation tempDirectory=“E:ASP.Net Temporary Folder” debug=false“>

One can find the documentation of all different sections of ASP.net configuration file at:
http://msdn2.microsoft.com/en-us/library/b5ysx397(VS.71).aspx

In case when Internet is not available, or you just need a quick reference, there is also a small helpful file in the configuration folder. This file is named “web.config.comments” and is in the CONFIG folder of the ASP.net framework folder.