简体   繁体   English

尝试创建目录时拒绝.NET MVC访问

[英].NET MVC Access denied when trying to create Directory

I am trying to create a Directory in .NET using Directory.CreateDirectory , I followed the directions here to give access permission but I am still getting an UnauthorizedAccessException. 我正在尝试使用Directory.CreateDirectory在.NET中创建Directory.CreateDirectory ,我按照此处的指示进行访问,但仍收到UnauthorizedAccessException。 Does anyone have any advice? 有人有建议吗? Note, this is a web application that uses the IIS7 server. 注意,这是一个使用IIS7服务器的Web应用程序。

In the directory you are attempting to create a new directory, make sure that your app pool user has Read/Write permissions for that directory. 在您试图创建新目录的目录中,请确保您的应用程序池用户对该目录具有读/写权限。 You have to specifically do that in addition to adding the user to the user groups. 除了将用户添加到用户组之外,还必须专门执行此操作。

2 more potential issues (+1 to user959729): 另外2个潜在问题(对user959729 +1):

  • you are creating directory at different place than you think you are (ie you building path wrong) 您正在与您认为不同的位置创建目录(即,您构建路径错误)
  • the code runs under impersonated account (user's or anonymous) and such user does not have permissions to create folder (to verify try check System.Environment.UserName before creating directory). 该代码在模拟帐户(用户或匿名帐户)下运行,并且该用户无权创建文件夹(要进行验证,请尝试在创建目录之前检查System.Environment.UserName )。 To fix you need to run code as process account. 要解决此问题,您需要以流程帐户身份运行代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM