Issue:
In ASP.NET applications, temporary files are generated during compilation and runtime. By default, these files are stored in system directory at: C:\Windows\Microsoft.NET\Framework[64]\<version>\Temporary ASP.NET Files\.
These ASP.NET temporary files include:
- Compiled assemblies (DLLs) of your web pages, user controls, and other server-side code.
- Cached versions of resources like Razor views (.cshtml), Web Forms (.aspx), and other dynamic content.
- Intermediate files used during the build and runtime process.
This can lead to the following issues:
- Running out of space on the system drive (C:)
- Difficulty in managing or monitoring temp files
- Performance bottlenecks on slower disks
Resolution:
You can resolve this issue by changing the location of ASP.NET temporary files using the tempDirectory attribute in web.config. This allows you to redirect ASP.NET to use a custom directory for temporary files by modifying your web.config as follows:
<system.web>
<compilation tempDirectory="E:\TemporaryASPNETFiles" />
</system.web>
Ensure the custom folder (E:\TemporaryASPNETFiles) is:
- Created manually before use.
- Writable by the IIS App Pool identity, e.g., IIS APPPOOL\YourAppPoolName. You can set permissions via File Explorer or using PowerShell.
After making this change:
- Recycle the application pool or
- Restart IIS using iisreset to apply the new configuration
Important Note:
This setting is valid for ASP.NET (System.Web) applications running on the .NET Framework. It does not apply to ASP.NET Core.