Welcome to MSDN Blogs Sign in | Join | Help

Notes from a dark corner

Debugging ASP.NET, the CLR and anything that uses clock cycles.

News

  • These postings are provided as is with no warranties, and confers no rights. Additionally, views expressed herein are my own and not those of my employer, Microsoft.
Clearing out "temporary asp.net files"

When I am testing out issues with ASP.NET dynamic compilation and shadow copying, I frequently need to ensure the contents of the "temporary asp.net files" folder have been removed so that I get a clean and consistent repro each time.

Normally I just do an IISRESET /STOP, delete the files manually and then do an IISRESET /START.

But I got bored of that so thought I would try to automate it with a command file.

First thought was to do a DEL /S "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\*.*"

This worked, but left the directory structure in place.

So my next thought was to do an RMDIR /S /Q "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files" and then just recreate the directory.

That certainly left me with an empty directory, BUT, the "NETWORK SERVICE" account under which my application pools usually run had no permissions to the newly created folder, so I got an "access denied" error as soon as I tried to browse an ASP.NET page.

Then I thougt I'd get clever and use the built in command line tool CACLS.EXE to give full control permissions to the built in IIS_WPG local group of which NETWORK SERVICE is a paid up member. (Any account you use as the identity for an application pool should be added to IIS_WPG rather than trying to give the account all the needed permissions directly. It's much simpler and more maintainable.)

What I didn't like about that was that CACLS.EXE does not appear to support a way of suppressing the "are you sure (Y/N)?" prompts.

So finally I grabbed a copy of XCACLS.VBS and got the following command file working:

 

iisreset /stop
rmdir /q /s "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files"
rmdir /q /s "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"
md "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files"
md "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"
xcacls "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files" /E /G MYMACHINE\IIS_WPG:F /Q
xcacls "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" /E /G MYMACHINE\IIS_WPG:F /Q
iisreset /start

 

HTH

Doug

Posted: Monday, August 11, 2008 7:59 AM by dougste
Filed under: ,

Comments

Christopher_G_Lewis said:

Hmm...

for /d %i in ("%systemroot%\Microsoft.Net\Framework\v2.0.50727\Temporary ASP.NET Files\*") do RD /q/s %i

(use %%i in batch files)

would be much safer...

# August 11, 2008 9:17 AM

dougste said:

Hi Christopher

A point I should have made is that this is a method I put together that works for me and I am using it on test machines rather than production servers.

Be interesting to know which of the two methods would be most performant especially in the case of large amounts of cached files.

Also, I'm curious to understand what might be "unsafe" about the method I suggested?

Thanks!  

Doug

# August 11, 2008 9:39 AM

Matt Johnson's Technical Adventures said:

Ask the Directory Services Team : MCS Talks Infrastructure Architecture joeware - never stop exploring…

# August 14, 2008 1:06 PM

paulo_teixeira said:

Another simple way to do this is using robocopy. Just create an empty folder in some place and them run robocopy with /MIR. For example:

md %TEMP%\empty

robocopy %TEMP%\empty "%systemroot%\Microsoft.Net\Framework\v2.0.50727\Temporary ASP.NET Files" /MIR

rd %TEMP%\empty

about safety, i've no idea, but it has less code, and it's very possible that is faster for a large number of files ;-)  

# August 15, 2008 9:36 PM

Dirk Van den Berghe SharePoint Admin Blog said:

This article is all about the C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files

# January 13, 2009 2:09 AM
Anonymous comments are disabled
Page view tracker