asp.net - 访问路径 'c:\inetpub\wwwroot\myapp\App_Data'被拒绝

标签 asp.net iis access-denied

我刚刚在 Windows XP 上安装了 IIS。

当我尝试执行应用程序时,出现错误:

Access to the path 'c:\inetpub\wwwroot\myapp\App_Data' is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 'c:\inetpub\wwwroot\myapp\App_Data' 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.

Source Error:

Line 70: Protected Sub cmbSettingFiles_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbSettingFiles.SelectedIndexChanged
Line 71: Dim doc As XmlDocument = New XmlDocument()
Line 72: doc.Load(Path.Combine(basePath, cmbSettingFiles.SelectedValue)) Line 74: Dim settingsNode As XmlNode = doc.SelectSingleNode("/settings")

Source File: C:\myapp\install\install.aspx.vb Line: 72

我尝试通过这样做来获得许可:

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.

但错误仍然存​​在。

这和我的代码有什么关系吗?

我该如何解决这个问题?

编辑

我已经解决了我的开发机器上的问题,但我的网络服务器上仍然收到错误。

谢谢。

最佳答案

如果您收到此错误,您可能正在尝试写入 wwwroot。默认情况下不允许这样做,for good reason .

相反,请考虑将文件存储在 wwwroot 之外的位置。如果您只需要提供文件,请将它们存储在 inetpub外部文件夹中,并使用 virtual directory使它们对 IIS 可见。

原答案:

<小时/>

对于在 Windows Server 上运行 IIS 的用户:

默认情况下,IIS 用户没有 wwwroot 文件夹的写入权限。这可以通过向 IIS_IUSRS 用户授予 wwwroot 的完全权限来解决。

  1. 打开文件资源管理器并转到 C:/inetpub/
  2. 右键单击 wwwroot,然后单击“属性”
  3. 转到“安全”选项卡并点击“编辑...”以编辑权限
  4. 查找并选择 IIS 用户。在我的例子中,它被称为IIS_IUSRS([服务器名称]\IIS_IUSRS)
  5. 选中所有权限的“允许”复选框。

关于asp.net - 访问路径 'c:\inetpub\wwwroot\myapp\App_Data'被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10255790/

相关文章:

c# - 如何在 C# 的 Web 应用程序中从服务器加载图像

c# - 使链接从 window.open 弹出窗口中消失

javascript - 未捕获的语法错误 : Unexpected token < in inline. bundle.js:1 - Angular v4

C# UWP 地理定位,访问被拒绝

java - 我的 JApplet 无法写入我的 APPDATA 文件夹

c# - 允许用户上传 .MOV 视频文件并在网站上显示

asp.net - 如何获得干净的 ASP.Net 错误页面?

c# - WebResource.axd 和 ScriptResource.axd 加载非常慢

MySQL 错误 1045 (28000) : Access denied for user 'bill' @'localhost' (using password: YES)

c# - onkeyup 事件 asp.net