167

Can I safely delete the contents of this folder

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root

on a Windows 2003 R2 standard system, given that I am not using IIS (6/7) on it?

If that is the case, could you please point me to the relevant documentation about ASP.NET's runtime and maintenance tasks such as this?

Community
  • 1
  • 1
Andrea Scarcella
  • 3,233
  • 2
  • 22
  • 26

2 Answers2

173

Yes, it's safe to delete these, although it may force a dynamic recompilation of any .NET applications you run on the server.

For background, see the Understanding ASP.NET dynamic compilation article on MSDN.

dthrasher
  • 40,656
  • 34
  • 113
  • 139
  • Thanks for your answer, I really hope I'll eventually be able to return the favour! – Andrea Scarcella Jul 03 '13 at 11:48
  • 45
    Worth noting that you mustn't delete the Temporary ASP.NET Files folder itself but you can clear its contents. – Piedone Oct 08 '14 at 13:36
  • 3
    Cleaning this folder fixed a wrong dependency version detection in a InstallShield LE Setup project. (My main assembly had a reference to EntityFramework 6.4 but IS packaged a 4.4, which was in that folder) – Jerther Apr 20 '15 at 19:13
  • I can't see anything in the referenced article that indicates it's safe to delete the files. The internet seems to either say it's safe to delete, or that you must stop IIS first, which is it? – Russell Horwood Sep 01 '20 at 15:53
  • 2
    @NineTails First, stop the app pool associated with the app folder under ".../Temporary ASP.NET/" you want to delete. Otherwise, it will keep a lock on it. Seems safe to delete. Once you start the app pool back up and hit the app again, the files will be regenerated. I'm running into an issue where it's trying to reference a file that doesn't exist there and haven't gotten to the bottom of it yet. – Inphinite Phractals Sep 10 '20 at 17:02
39

Just an update on more current OS's (Vista, Win7, etc.) - the temp file path has changed may be different based on several variables. The items below are not definitive, however, they are a few I have encountered:

"temp" environment variable setting - then it would be:

%temp%\Temporary ASP.NET Files

Permissions and what application/process (VS, IIS, IIS Express) is running the .Net compiler. Accessing the C:\WINDOWS\Microsoft.NET\Framework folders requires elevated permissions and if you are not developing under an account with sufficient permissions then this folder might be used:

c:\Users\[youruserid]\AppData\Local\Temp\Temporary ASP.NET Files

There are also cases where the temp folder can be set via config for a machine or site specific using this:

<compilation tempDirectory="d:\MyTempPlace" />

I even have a funky setup at work where we don't run Admin by default, plus the IT guys have login scripts that set %temp% and I get temp files in 3 different locations depending on what is compiling things! And I'm still not certain about how these paths get picked....sigh.

Still, dthrasher is correct, you can just delete these and VS and IIS will just recompile them as needed.

Jester
  • 2,728
  • 22
  • 20
  • 14
    You are incorrect. `C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files` still contains dynamically compiled assemblies. – Ross Presser Feb 23 '16 at 16:10
  • 2
    Actually, it's both - I have some systems where its the Framework folder, and others where it's the AppData folder...I'll see if I can figure out the diff....arg – Jester Feb 25 '16 at 01:17
  • I would guess that if your website runs in IIS, it would always be under Framework. – Ross Presser Feb 25 '16 at 14:31
  • 2
    On second thought maybe it depends what identity your application pool uses. – Ross Presser Apr 01 '16 at 18:55