NetworkService in IIS has an empty path to AppData

Using IIS 8 on Windows 8, I configured an application pool that works with the Network Service identifier.

In the code for the page, I call:

 Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) 

Both calls return null.

I tried the <identity impersonate="true|false"/> combinations and also set the Load User Profile parameter to true | false in setting up the application pool, but always get a null result.

I would expect to get one of:

 C:\Windows\ServiceProfiles\NetworkService\AppData\Local C:\Windows\System32\config\systemprofile\AppData\Local 

On another user computer, they get the second folder as the path (IIS 7.5), although the application pool acts as a Network Service.

What can happen to these profile folders?

+4
source share
2 answers

It seems to me that you need the parameter LoadUserProfile, as well as one additional call from the console:

cd "% ~ dp0" md appdata p>

This will create the necessary folder for the application pool user. I'm not sure if this will cause Environment.SpecialFolder.ApplicationData to return the correct path.

0
source

In %WINDIR%\System32\inetsrv\config\applicationHost.config find <applicationPoolDefaults> . In the <processModel> section, make sure you do not have setProfileEnvironment="false" . If you do, set it to true.

0
source

All Articles