本文介绍了共享计算机中服务器上的CreateDirectory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在共享.NET服务器上运行的ASP.NET应用程序.我想允许当前登录的用户在应用程序需要时将其创建到特定路径的文件夹.因此,我只是检查以下内容:

I have an ASP.NET application running over a shared .NET server. I want to allow the current logged user to create a folder into a specific path when the application needs it. So, I'm just checking the following:

var userFolderPath = Path.Combine(Server.MapPath("~/storedphotos"), username);
if (!Directory.Exists(userFolderPath)) {
    Directory.Create(userFolderPath);
}

当我在本地计算机上运行此代码时,它可以完美运行.但是,当我将应用程序发布到该服务器并尝试执行相同操作时,它返回了我:

When I run this code into my local machine it works perfectly. However, when I publish the application to that server and try to do the same, it's returning me:

"Access to the path 'xxxxxx' is denied."

我认为这可能是权限问题.一旦无法在IIS上将任何内容更改为服务器或任何配置,是否有办法让用户使用我的应用程序创建文件夹而不会出现问题?

I think it could be a permission issue. Once I cannot change anything at the IIS into the server or any configuration, is there a way to let the user is using my application to create the folder without problems?

推荐答案

尝试一下:

如错误所述,您需要为文件夹分配权限

As Error says You need to assign Permissions to Folders

  1. 右键单击文件夹
  2. 转到安全性"标签
  3. 单击编辑"
  4. 点击添加
  5. 点击高级
  6. 立即查找
  7. 授予IIS_IUSRS(完全控制)权限
  8. 单击确定"
  9. 单击确定"
  10. 单击允许中的Full Control
  11. 单击确定"
  12. 再次运行应用程序
  1. Right Click Folder
  2. Go to Security Tab
  3. Click on Edit
  4. Click on Add
  5. Click on Addvance
  6. Find Now
  7. Give Permission to IIS_IUSRS (Full Control)
  8. Click On OK
  9. Click On OK
  10. Click On Full Control in allow
  11. Click On OK
  12. Again Run the Application

注意::如果上述操作均无效,请尝试授予相同的权限NETWORKNETWORK SERVICE用户

Note: If Above things are not working then try to give same permission toNETWORK,NETWORK SERVICE Users

这篇关于共享计算机中服务器上的CreateDirectory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 05:27
查看更多