无法通过 asmx Web 服务创建目录

发布于 2024-08-14 13:43:52 字数 400 浏览 2 评论 0原文

我正在尝试创建一个目录,然后通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

赠我空喜 2024-08-21 13:43:52

我的第一个建议是确保 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.

雨巷深深 2024-08-21 13:43:52

如果您收到访问被拒绝错误,那么这就是访问被拒绝错误。它是通过网络服务发生的并不重要。像诊断任何其他访问被拒绝错误一样对其进行诊断。

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.

海的爱人是光 2024-08-21 13:43:52

您需要授予该目录的“网络服务”写入权限。请检查您正在使用哪个操作系统。它可能需要不同的帐户。

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.

笑,眼淚并存 2024-08-21 13:43:52

对于任何正在寻找的人。下面的代码就达到了目的:

Directory.CreateDirectory(Server.MapPath(directoryName)); 

For anyone searching. The following code did the trick:

Directory.CreateDirectory(Server.MapPath(directoryName)); 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文