views:

388

answers:

2

I have a ASP.NET + some .NET web-services running on IIS 6 (win 2003 server). The issue is that IIS is generating a lot (!) of files in "c:\WINDOWS\Temp" directory. a lot of files means thousands of files, which get to more than 3G of size so far.

The files are generated by this command: C:\WINDOWS\SysWOW64\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\vfagt\113819dd\db0d5802\assembly\dl3\fedc6ef1\006e24d8_3bc9ca01\VfAgentWService.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /out:"C:\WINDOWS\TEMP\9i_i2bmg.dll" /debug- /optimize+ /nostdlib /D:_DYNAMIC_XMLSERIALIZER_COMPILATION "C:\WINDOWS\TEMP\9i_i2bmg.0.cs"

The files in the temp directory are pairs of *.out & *.err, where the *.err file is zero size, and the *.out file contains the compilation output messages.

What is causing IIS to generate so many files?

How can I prevent it?

UPDATE:

The problem is that the command i described above (csc.exe) is being executed many (many) times, causing the .out & .err to be generated so many times, until it consumes the disk space.

So - my question is: what is causing this command to run so many times? (i don't have that many .aspx & .asmx files in my web app).

Thanks, Moe

A: 

You can't prevent it. IIS + ASP.NET dynamically compile files like .aspx, .asmx, .ascx, .ashx, .asax, and others. These are all template files, that eventually get transformed into source code in the chosen language - C#, VB.NET, or whatever you choose to write your ASPX pages in.

The model for ASP.NET, when a request for a page is received, is this:

  • check to see if an assembly for the requested page is available and up to date. if it is, pass the request to the page.
  • if not, produce source code from the templates involved (aspx, ascx, etc). Put the generated source code into the ASP.NET Temp directory.
  • compile the source files into assemblies that are dynamically named and also placed in the temporary directory. If you use C#, that means it runs csc.exe, as you have seen.
  • load the newly compiled assembly.
  • pass the request to that assembly (eg, step 1)

The .out and .err files are just the stdout and stderr from the invocation of csc.exe. Those are not likely to consume 3gb of filesystem space.

But, ASPNET also keeps temp copies of all assemblies referenced by any of the pages or controls (etc), in that directory tree. If you reference System.Xml.dll in three distinct ASPX pages, then there is a copy of System.Xml.dll places into three distinct temp directories in the ASPNET temporary files dir tree. These copies can accumulate and it wouldn't surprise me to hear that most of your 3gb is in copies of DLLs.

Read more about this at http://www.codeproject.com/KB/aspnet/ASPXFILES.aspx

You can delete any files in the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files directory. This won't be possible while IIS and ASP.NET are active. If you have a maintenance period, you can delete them when the site is down. If it's a dev machine, just stop IIS (net stop w3svc) delete all subdirectories in that folder, then restart IIS (net start w3svc).


Related:
- Eliminating temporary ASP.Net Files
- What is the “Temporary ASP.NET Files” folder for?

Cheeso
It's possible there's a problem with the timestamps. ASPNET decides to run the compiler if the compiled output is timestamped later than the .aspx file. If, for example, you had an ASPX file timestamped to some time in the future (possible, though not sensible), then ASPNET would never decide that it does not need to be re-compiled. My advice is to stop IIS, delete the temp files folder, and then check and correct the timestamps on all your ASPX files, etc.
Cheeso
A: 

Not sure if this help but here you have a couple of links that describes a similar situation

http://geekswithblogs.net/akraus1/archive/2009/09/14/134820.aspx

http://social.msdn.microsoft.com/Forums/en-US/netfxremoting/thread/fddb5072-f84b-432a-945a-607e183e1da3

Claudio Redi