How .Net names its temp folder inside C:\\Windows\

2019-08-08 23:00发布

问题:

I have some websites on my IIS machine. Lets say WebsiteA, WebsiteB and WebsiteC.

Inside .Net temp folder

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\{folderName}

each of the 3 website will have their own folder with some random name.

For example:

  • WebsiteA is using a folder named 5a3e1z1j. This folder will have the following path :

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\5a3e1z1j

  • WebsiteB is using a folder named b51o8881. This folder will have the following path :

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b51o8881

  • WebsiteC is using a folder named ad4966a9. This folder will have the following path:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ad4966a9

How do I know which website is using which folder? So while the process of that website is still running, it won't allow me to delete the folder. It will only allow to delete the folder if I kill the process / stop the application pool or IIS.

Then I did some testing, what if I delete the folder (of course while there is no running process), what will happen to the site.

So apparently it will create a new folder with same exact random name.

Then I come up with a conclusion that this name is stored somewhere, so even though the folder is deleted. It will be recreated back with the same name.

My question is "How .Net create the name of these .Net temp folder so that for each website will have a consistent folder name? If it's stored somewhere after a successful build of the website, where can I find it?"

What I am trying to achieve is I want to create a tool that will do application pool restart if it's given input of website name. And also at the same time delete the .Net temp folder. But only the one associated to the input website.

If something is not clear, please let me know.

Thanks