导航

asp.net临时文件的重定向

Posted on 2013-03-21 10:57  理工.net  阅读(182)  评论(0编辑  收藏  举报

从网上搜索到下面这段文字,自己实践成功后贴出来备忘:

 

Relocating Temporary ASP.NET Files

Posted by Chris Alcock on Monday 15th October 2007 at 10:29 pm | Tagged as: .NET, ASP.NET, Development, IIS, SysAdmin

When you first request a page from the an ASP.NET application, the .NET framework takes the ASPX file and generates code to actually execute the page. This code is then compiled by the framework and the results of the compilation are stored in the Temporary ASP.NET files directory within the framework directory (usually located in c:\windows\Microsoft.NET\Framework). When the ASPX of the compiled DLL changes this code is re-generated and recompiled.
On a server that hosts lots of ASP.NET applications this store of temporary compiled code can occupy a considerable amount of space. On machines with a limited amount of space on their OS partition this can begin to cause problems. Thankfully the ASP.NET framework does allow the location of this directory to be specified as a custom location.
As with most server wide settings you need to make a change to the Machine.Config (for .NET 1.1) or Machine wide web.Config (for .NET 2). The crucial part of the configuration is the Compilation element within system.web. The compilation element has an optional attribute called tempDirectory that allows a new directory location to be specified overriding the default setting of %FrameworkInstallLocation%\Temporary ASP.NET Files.

<system.web>

   <compilation tempDirectory="d:\TempASP.NETFiles\">

      ...

   </compilation>

</system.web>

One thing to watch out for when making this change is the file permissions on your new Temporary ASP.NET files - copying the permissions from the original location will do the trick nicely.