Tuesday, August 19, 2014

Removing Temporary ASP.NET Files


I was recently making some radical changes to an ASP.NET Application in order to upgrade it with the latest suite of controls and in order to migrate/upgrade the functionality I was running one project with the older suite of controls while the other project was running with the newer suite of controls.

As you may know, IIS (as well as IIS Express) cache this content in the Temporary ASP.NET Files directory in order to improve performance of loading these applications.

Therefore, because there was a conflict in the caching of these files, I was not able to run and debug the application in Visual Studio.

When I then tried to consequently delete the contents in the Temporary ASP.NET Files directory, I kept on getting an “Access Denied” error message indicating that something was still locking the files thereby preventing the files from being deleted.  I stopped both IIS Express as well as the World Wide Publishing Service, but this was to no avail.

I then followed the good old credo of “whenever in doubt, reboot the machine”.  Naturally, after rebooting the machine, I was able to successfully run this PowerShell script to delete all of the Temporary ASP.NET Files:

Get-ChildItem "C:\Windows\Microsoft.NET\Framework*\v*\Temporary ASP.NET Files" -Recurse | Remove-Item -Recurse

After all of the Temporary ASP.NET Files were deleted, I was able to successfully run and debug my application within Visual Studio!

1 comment:

  1. Wow, really very nice information for me. Thank you very much. I have recently hosted my site from myasp.net. If I needed than used your technique….