NetworkService under IIS has empty AppData path

删除回忆录丶 提交于 2019-12-21 05:23:11

问题


Using IIS 8 on Windows 8, I've set up an application pool which runs with an identity of Network Service.

In the code for a page, I make calls to:

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

Both calls return null.

I've tried combinations <identity impersonate="true|false"/> as well as setting the Load User Profile setting to true|false in the application pool setting, but I 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's machine, they get the second folder as the path (IIS 7.5) even though the application pool runs as Network Service.

What could be happening with these profile folders?


回答1:


In your %WINDIR%\System32\inetsrv\config\applicationHost.config look for <applicationPoolDefaults>. Under <processModel>, make sure you don't have setProfileEnvironment="false". If you do, set it to true.




回答2:


I think you need the LoadUserProfile setting as well as one additional call from a console:

cd "%~dp0" md appdata

This would create the required folder for the app pool user. I'm not sure if this will result in Environment.SpecialFolder.ApplicationData returning a correct path though.



来源:https://stackoverflow.com/questions/12056626/networkservice-under-iis-has-empty-appdata-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!