How To: Optimizing Disk usage by Temporary ASP .NET Files

How To: Optimizing Disk usage by Temporary ASP .NET Files

  

Permalink: www.outsystems.com/goto/optimizing-temp-aspnet-files

The .NET Framework compiles Web pages and code files dynamically, when users request a resource for the first time of an ASP.NET application (e.g., an .aspx file from a Web site). After pages and code files are compiled the output is cached, so that subsequent requests to the resources are more efficient. This cached content is called "Temporary ASP .NET Files". You can get info about this issue at: Understanding ASP.NET Dynamic Compilation

The content produced by the Agile Platform (.NET stack only) is hosted by the application server IIS as ASP.NET applications. On the event of an eSpace deployment, old binary data may remain at the Temporary ASP .NET folders, if not deleted, can cause considerable disk usage overhead, e.g., development environments with heavy deployment rates.

The ASPNETTempFilesCleanup.bat script in attachment, provides the means to erase old Temporary ASP .NET folders that are no longer being used. This task can be performed manually on-demand, or it can be configured as a Windows OS scheduled task.

As an example, the command can be used in the following manner, in a command prompt:

ASPNETTempFilesCleanup "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"

This script is provided as "as is", without any warranty, and you must use it at your own risk. Also, feel free to customize it according to your own requirements.

Hope you enjoy it,
Cristóvão Honorato

Additionally to the option of cleaning them up frequently, you might want to change the location of your Temporary ASP.NET files. By default, they are created under c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files (e.g. for 32-bit .NET 2.0) but you can change it to whatever location you want - particularly to a different partition.

 

In order to do so, you can use the tempDirectory parameter in the <compilation> tag in web.config / machine.config. Documentation from Microsoft to this option can be found in:

To make matters simple, you can simply open your global web.config, locate the compilation tag under system.web and append the attribute. E.g.:

  • <compilation tempDirectory="D:\TempASP.NET">

Remember not to append the / to the end of the tag, since this tag usually has further options defined / children nodes.

 

Final recommendations:

  • Remember to create the directory before using it;
  • Make sure that IIS_WPG has read and write privileges over the folder;
  • If you are using a particular domain user to run some eSpaces (Run-As option) make sure to grant that user read and write privileges over the folder also.

 

Hi, isn't it possible to build-in this batch job in the platform?

I don't know how a single eSpace got a .NET temporary folder up to 12 GB, but it scared me...

Best Regards,

Diogo C S Cordeiro
Yeah, there's definately a possibility evidence to add it on the product ... it's a matter of when.

I've added the Idea on the Wisdom of the Crowds, so vote on it.

Cheers

Miguel Simões João
Hi guys my folder ara ever empty, how can I discover where temporary files are saved?
Alexandre Costa wrote:
Hi guys my folder ara ever empty, how can I discover where temporary files are saved?
 
 Hi Alexandre

If your temporary asp.net files aren't on C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files then check the folder C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files.

If the neither folder have your temporary asp.net files then checkout the configuration <compilation tempDirectory="<some folder here>"> on your machine.config file.

Cheers

Miguel Simões João
In an EC2 hosted environment, would it be advisable to define the instance storage as the location of your Temporary ASP.NET files?
André Ramos wrote:
In an EC2 hosted environment, would it be advisable to define the instance storage as the location of your Temporary ASP.NET files?
 
Definitely Yes!

Instance storage is better suited for temporary files (from ASP.NET or other sources) because:
  • it's faster to access (local access, no network involved, no replica synchronization required)
  • you don't pay for accessing it (there's a small fee for EBS IO operations... it's small but it's there)
  • it's temporary files on a temporary storage (instance storage persistance is guaranteed only while the instance is running)
See Acácio's reply on how to configure the location of the ASP.NET temporary files.
This morning I received an alert of disk above 90%.
It was easy to find: 50% of the disk was used by that folder. Some projects have being there for more than a year, but around 30GB were in 3 projects with eight, six and three months. It's amazing how fast it grows (how useless it is) and an automatic cleanup should be implemented.

The ideia just got another like!
Hi All, 

Can you let me know how to run this clean up batch file. I am getting bad parameter error and want to know where you will insert the path.

With regards
Saravan
Hello Saravanan,

The example in the post most post shows how to use it. It's very straight forward.

Can you share how you're using the script? Maybe we can help by checking your command line.

Thanks

Cheers