通过Environment.GetFolderPath(Environment.SpecialFolder.ApplicationFolder)在IIS6 WebService的返回路径错误 [英] Wrong path returned by Environment.GetFolderPath(Environment.SpecialFolder.ApplicationFolder) under IIS6 WebService

查看:675
本文介绍了通过Environment.GetFolderPath(Environment.SpecialFolder.ApplicationFolder)在IIS6 WebService的返回路径错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的测试机器上运行(Windows XP中,IIS5.1)在C#.NET的WebService(.SVC)根据自定义的进程标识执行以下code(使用machine.config中指定的用户)

On my test machine running (Windows XP, IIS5.1) the following code executed within a C# .NET WebService (.SVC) under a custom process identity (using machine.config to specify the user)

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

正确返回

c:\Documents and Settings\myUserName\Application Data

不过,在(终端服务)Windows 2003计算机上运行IIS6和执行相同的code,但现在用ApplicationPool指定相同的进程标识的方法的返回值:

However, on (Terminal Services) Windows 2003 machine running IIS6 and executing the same code but now using ApplicationPool to specify the same process identity the method returns:

c:\Documents and Settings\Default User\Application Data

事情我已经检查了Win2003的/ IIS6的机器上运行时:

Things I have checked while running on the Win2003/IIS6 machine:

  1. 名为myUsername所属的组IIS_WPG(甚至试图联系)
  2. 调用Environment.UserName正确返回MyUserName输入
  3. 调用的 Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); 的也返回了默认用户的路径,也有DesktopDirectory
  4. 在登录名为myUsername,并确保的 C:\ Documents和Settings \ MyUserName输入的存在
  5. 在上在Windows 2003中一个.NET应用程序中运行完全相同的code,这部作品并返回正确路径。
  1. myUserName belongs to the group IIS_WPG (even tried Admin)
  2. a call to Environment.UserName correctly returns myUserName
  3. a call to Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); also returns a 'Default User' path, likewise with DesktopDirectory
  4. logged on as myUserName and ensured that C:\Documents and settings\myUserName exists
  5. running the exact same code in a .net application on the Windows 2003 box, this works and returns the correct path.

我百思不得其解,只IIS6下乳宁时出现。这几乎就像它认为该呼叫从网络服务本地系统用户来了,它不是检查运行应用程序池的标识。

I am baffled, it only occurs when runing under IIS6. It is almost like it thinks that the call is coming from Network Service or Local System users and it is not checking the Identity running the Application Pool.

顺便说一句,当我看着procmon中,看是从它有没有这样的问题,读,写的 C中的Web服务被称为C ++应用程序:\的Documents and Settings \ MyUserName输入\ ApplicatonData 的,它不似乎有一个问题,也许它构建的路径是不同的。

Incidentally when I look at Procmon and watch a C++ application that is called from the webservice it has no such problem reading and writing to C:\Documents and settings\myUserName\ApplicatonData, it does not seem to have a problem, perhaps it builds the path differently.

我开始认为这可能是在.NET中的一个错误??

I am starting to think this might be a bug in .NET??

感谢。

汤姆Deloford

Tom Deloford

推荐答案

解决。显然,这是'设计',因为IIS6不会加载用户配置文件设置。

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

微软建议我升级到IIS7或致电LoadUserProfile第一,我不知道是什么促使他们改变从IIS5.1的功能。

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

<一个href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/890fa85a-b11a-4fbe-a333-cbe69abd72a7" rel="nofollow">http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/890fa85a-b11a-4fbe-a333-cbe69abd72a7

反正教训,不要以为功能并没有被删除,并始终以同一个应用程序服务器上测试,即使惹恼了IT部门!

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!

这篇关于通过Environment.GetFolderPath(Environment.SpecialFolder.ApplicationFolder)在IIS6 WebService的返回路径错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆