Wrong path returned by Environment.GetFolderPath(Environment.SpecialFolder.ApplicationFolder) under IIS6 WebService

假装没事ソ 提交于 2019-11-29 15:39:50

Solved. Apparently this is 'by design' because IIS6 does not load user profile settings.

Microsoft advised me to upgrade to IIS7 or call LoadUserProfile first, I wonder what possessed them to change that functionality from IIS5.1.

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/890fa85a-b11a-4fbe-a333-cbe69abd72a7

Anyway lesson learned, don't assume functionality hasn't been removed and always test with the same application server even if annoys the IT department!

Yes. it's not a bug. Under which user is running the app pool??

Let's split this a little:

The Test Machine uses IIS to host the service or the built-in web server? If you use the built-in web server, it runs under your user. If you use IIS, which one is the pool user?

If it is Network Service or Local System, the process runs under the context of one of those users, and indeed, the call to:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) 

is OK.

You should change the user of the pool (and recycle the pool) to see the change.

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