远程服务器上文件夹的写权限
我在 localhost 托管一个网站,需要使用 FileUploadControl 将图像文件上传到另一个名为 ImageServer 的服务器。
if (FileUploadControl.HasFile)
{
try
{
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(@"\\ImageServer\" + filename);
}
catch (Exception ex)
{
throw;
}
}
但当我尝试提交图像时,我就遇到了此权限错误。
异常详细信息:System.UnauthorizedAccessException:对路径“\ImageServer\xxx.jpg”的访问被拒绝。
ASP.NET 无权访问所请求的资源。考虑 向 ASP.NET 请求授予对资源的访问权限 身份。 ASP.NET 有一个基本进程标识(通常是 IIS 5 上的 {MACHINE}\ASPNET 或 IIS 6 上的网络服务),如果 该应用程序不是冒充的。如果应用程序是 冒充 via ,身份将是 匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的用户 请求用户。要授予 ASP.NET 对文件的访问权限,请右键单击该文件 在资源管理器中,选择“属性”并选择“安全”选项卡。点击 “添加”添加适当的用户或组。突出显示 ASP.NET 帐户,然后选中所需访问权限的复选框。
我查看了文件夹安全选项卡,网络服务、IUSR、IIS AppPool\Image 和Everyone 被授予完全控制权。还可能缺少什么?我不确定应该向 ImageServer 上的图像文件夹授予什么权限,以让我的本地主机向它们写入文件。
P/S:两台服务器都使用 IIS 7.5
通过 Windows 资源管理器手动将文件复制到 \\ImageServer\
I'm hosting a web site at localhost and need to upload image file to another server named ImageServer with the FileUploadControl.
if (FileUploadControl.HasFile)
{
try
{
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(@"\\ImageServer\" + filename);
}
catch (Exception ex)
{
throw;
}
}
But i hit this permission error as soon as i try to submit an image.
Exception Details: System.UnauthorizedAccessException: Access to the path '\ImageServer\xxx.jpg' is denied.
ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request
identity. ASP.NET has a base process identity (typically
{MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if
the application is not impersonating. If the application is
impersonating via , the identity will be
the anonymous user (typically IUSR_MACHINENAME) or the authenticated
request user. To grant ASP.NET access to a file, right-click the file
in Explorer, choose "Properties" and select the Security tab. Click
"Add" to add the appropriate user or group. Highlight the ASP.NET
account, and check the boxes for the desired access.
I looked into the folder security tab, and Network Service, IUSR, IIS AppPool\Image, and Everyone are granted full control. What else could be missing? I'm not sure what permission should i give to the image folder on ImageServer to let my localhost writing files to them.
P/S: Both server using IIS 7.5
Manually copy files to \\ImageServer\ via windows explorer works though
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主要技巧是创建一个指向 \\ImageServer\ 的虚拟目录。
我在此处找到了一篇文章。虽然是关于 IIS 6,但我认为在 IIS 7 上工作也不会成为问题。
The main trick is to create a virtual dir which points at \\ImageServer\.
I found an article here. Although is about IIS 6 I think it won't be a problem to work on IIS 7 also.