无法通过 asmx Web 服务创建目录
我正在尝试创建一个目录,然后通过 asmx Web 服务写入该目录。它在我的开发电脑上运行良好,但是当我将服务发布到服务器时,我不断收到访问被拒绝的错误。我已进入 IIS 并确保该服务具有写入权限。我还向所有用户授予了写入权限,但仍然遇到相同的错误。有什么建议吗?
其他信息 好吧,我解决了这个问题。当我打电话时,
Directory.CreateDirectory(directoryName);
它在我的开发盒上运行良好,但在服务器上崩溃了。我需要使用
Directory.CreateDirectory(Server.MapPath(directoryName));
which worked fine on both.I am trying to create a directory and then write to it via an asmx web service. It works fine on my dev pc, but when I publish the service to the server, I keep getting access denied errors. I have gone in to IIS and made sure the service has write privileges. I also gave write access to all users, but am still getting the same error. Any suggestions?
Additional info
Well, I solved the problem. When I called
Directory.CreateDirectory(directoryName);
it worked fine on my development box but blew up on the server. I needed to use
Directory.CreateDirectory(Server.MapPath(directoryName));
which worked fine on both.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我的第一个建议是确保 IIS 用户帐户有权访问该目录。
接下来我会说仔细检查你的代码。您是否正在尝试写入不存在的目录?您是否忘记更改配置设置。
当我遇到同样的问题时,99% 通常是权限问题。
My first suggestion is to make sure the IIS user account has access to the directory.
Next I would say double check your code. Are you trying to write to a directory that isn't there? Did you forget to change a config setting.
99% when I have had the same issues, it is usually a permissions issue.
如果您收到访问被拒绝错误,那么这就是访问被拒绝错误。它是通过网络服务发生的并不重要。像诊断任何其他访问被拒绝错误一样对其进行诊断。
If you're getting an access denied error, then it's an access denied error, period. It doesn't matter that it's happening from a web service. Diagnose it as you would diagnose any other access denied error.
您需要授予该目录的“网络服务”写入权限。请检查您正在使用哪个操作系统。它可能需要不同的帐户。
you need to give "Network Service" write permission for that directory. Please check which OS you are useing also. It may need a different account.
对于任何正在寻找的人。下面的代码就达到了目的:
For anyone searching. The following code did the trick: