Could not find a part of the path
ASP.NET Compilation Model can become troublesome for system administrators; especially if they are dealing with lousy developers/clients. 99% of the time; developers don’t bother to tweak the application for deployment into production; they XCOPY their ASP.NET apps to the web servers. They should beware of deploying DEBUG code as described in this article. The side affect of this is that lot of useless files start generating in Temporary ASP.NET Files folder. And if the system administrator is also lousy; who don’t bother to follow best practices; and tends to use out of box configurations; which might not be suitable all the time, things can turn worst.
Today I was contacted for a similar scenario; the problem they were having was due to lot of temporary ASP.NET files; their system drive (where ASP.NET temp files are generated out of box) becomes fragmented very often resulting downtimes due to defrags and other such disk management tasks. I suggested changing tempDirectory; (its attribute of <compilation> tag in machine.config) so that the files get generated on a separate disk. The interesting thing was that it didn’t work as expected; when running any ASP.NET application; we were having following exception.
[DirectoryNotFoundException: Could not find a part of the path "D:\".]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +287
System.IO.Directory.InternalCreateDirectory(String fullPath, String path) +489
System.IO.Directory.CreateDirectory(String path) +195
System.Web.Compilation.PreservedAssemblyEntry.DoFirstTimeInit(HttpContext context) +85
[HttpException (0x80004005): Failed to create temporary files directory 'D:\TempForAspNet11\root\5c683e08\45fe78ee'. Access denied.]
System.Web.Compilation.PreservedAssemblyEntry.DoFirstTimeInit(HttpContext context) +144
System.Web.Compilation.PreservedAssemblyEntry.EnsureFirstTimeInit(HttpContext context) +98
System.Web.Compilation.PreservedAssemblyEntry.GetPreservedAssemblyEntry(HttpContext context, String virtualPath, Boolean fApplicationFile) +28
System.Web.UI.TemplateParser.GetParserCacheItemInternal(Boolean fCreateIfNotFound) +178
System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String virtualPath, String inputFile, HttpContext context) +119
System.Web.UI.TemplateControlParser.GetCompiledInstance(String virtualPath, String inputFile, HttpContext context) +36
System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String virtualPath, String inputFile, HttpContext context) +43
System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String path) +44
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) +687
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +173
By chance I was aware of the fact that how System.IO.Directory.CreateDirectory(String path) works; this API tries to read attributes of all the folders/drive in the path to ensure that all folders/drive exists. Therefore you need to give “Read Attribute” permission to IIS_WPG group (Windows 2003) as shown below.
Slashdot Statement <smile />
Have you noticed Windows offers pretty flexible ACLs as compared to Unix/Linux; 14 types of ACLs as compared to 3
-Kernel Dev/Scholar in some interview at Channel 9