我试图保存一个图像到。net c#的文件夹,但我得到这个异常:

Access to the path 'C:\inetpub\wwwroot\mysite\images\savehere' is denied.The error occured at mscorlib because    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)

我完全控制了这个文件夹(savehere)到网络服务和iis_iusrs,甚至完全控制了每个人,但仍然得到这个异常。 我尝试通过浏览器和IIS管理器访问,仍然没有运气

我是在Windows server 2008 R2和IIS 7.5上做的,我需要给谁访问权限?


当前回答

在我的情况下,我必须在IIS中为网站添加一个. net授权规则。

我添加了一条允许匿名用户的规则。

其他回答

在我的情况下,我必须在IIS中为网站添加一个. net授权规则。

我添加了一条允许匿名用户的规则。

您需要从网站的应用程序池中找出它运行的身份(默认情况下是应用程序池身份),并授予正确的权限。

我的问题是,我必须要求只读访问:

FileStream fs = new FileStream(name, FileMode.Open, FileAccess.Read);

将“内置帐户”修改为“自定义帐户”,并输入另一台服务器的用户名和密码。 保持设置为集成模式(而不是经典模式)。

我在本地工作站上开发时遇到了这个问题。

在几次不成功的iisreset调用之后,我通过重新启动我的机器来纠正这种情况。

回顾一下,打开的文件句柄可能会导致问题。