How to determine the \Temporary ASP.NET Files\root\{site hash} with PowerShell?

前端 未结 2 1972
有刺的猬
有刺的猬 2021-02-09 07:14

ASP.NET makes use of a temporary files directory to store files for Shadow Copying and Dynamic Compilation. A typical path will look like this. Note the hash on the end of the p

2条回答
  •  不知归路
    2021-02-09 08:01

    Well, a few moments with Reflector, searching all members within System.Web for the word "Temporary" shows this call gets me here:

    string str2 = AppManagerAppDomainFactory.ConstructSimpleAppName(AppDomainAppVirtualPath);
    

    But then I remember that the source code is available for all of .NET, so I move to the actual code, rather than the reflectored code: https://referencesource.microsoft.com/#System.Web/HttpRuntime.cs,870

    Later in that method "SetupCodeGenDirectory" the path appears to be built on top of with

     this._codegenDir = Thread.GetDomain().DynamicDirectory;
    

    So, looks like that hash is from DynamicDirectory. That's over here at http://referencesource.microsoft.com/#mscorlib/system/appdomain.cs#2792 which looks like an extern that is inside some COM Fusion Loader stuff:

    [ComImport,InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("7c23ff90-33af-11d3-95da-00a024a85b51")]
    

    But that GUID leads me here http://referencesource.microsoft.com/#mscorlib/microsoft/win32/fusionwrap.cs#94

    which implies it's a public key token part:

         public const uint HASH_VALUE            = PUBLIC_KEY_TOKEN + 1;
         public const uint NAME                  = HASH_VALUE + 1;
    

    That perhaps it's NAME? I'm guessing it's yourAssembly.GetPublicKeyToken();

    OR, just change the folder that your temporary ASP.NET files go to in config section http://msdn.microsoft.com/en-us/library/system.web.configuration.compilationsection.tempdirectory%28VS.80%29.aspx in system.web in web.config

    
    

提交回复
热议问题