I got a request to look into the question, how do I delete temporary ASP.NET files on a shared Windows hosting server and I’ve decided to take a look into it.
Unless you have access to the global temp used by the server – which any good sysadmin will not allow – you can’t clear the global temp. However what you can do is change the temporary directory path used by your application.
The web.config file allows you to make application specific configuration changes, including the .NET temp file path. You can instead change the path to a location you do control.
How? Using the compilation Element, but more specifically the tempDirectory attribute. This attribute has existed since .NET 1.1, so it will work on all .NET version from 1.1 through to at least .NET 4.
<compilation tempDirectory=”D:\userdata\client224\temp” />
This is important! Remember to correctly set NTFS and/or share permissions on the new tempDirectory location else your application will not compile. You’ll need to apply read/write (modify) permissions to the folder using the application pool identity. This identity may be a system user like NETWORKSERVICE, IIS AppPool\AppPoolNameHere or another custom identity. For more on application pool identities, check the official documentation.
It’s reasonable for Windows shared hosting providers to want to disable this ability – I would – but I’ve not read any instances of it happening yet.
Best of luck!
- Automatically Clean Up Temporary ASP.NET Files
- ISAPI Filter ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\\aspnet_filter.dll’ could not be loaded due to a configuration problem
- Restore SQL Azure Backup to MSSQL Server
- What application pool is using all that CPU?
- Restoring broken Windows 2012 R2 Hyper-V directory permissions
- How to Stop sidebar.exe Using Lots of Memory (Edited 14 May 2011)
- Moving From No Control Panel Servers to a cPanel Server
- Error message “The file is either corrupted or does not have the latest credentials associated with recovery service. (ID: 34513) “