问题描述
我有一个在共享.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
- 右键单击文件夹
- 转到安全性"标签
- 单击编辑"
- 点击添加
- 点击高级
- 立即查找
- 授予
IIS_IUSRS
(完全控制)权限 - 单击确定"
- 单击确定"
- 单击允许中的
Full Control
- 单击确定"
- 再次运行应用程序
- Right Click Folder
- Go to Security Tab
- Click on Edit
- Click on Add
- Click on Addvance
- Find Now
- Give Permission to
IIS_IUSRS
(Full Control) - Click On OK
- Click On OK
- Click On
Full Control
in allow - Click On OK
- Again Run the Application
注意::如果上述操作均无效,请尝试授予相同的权限NETWORK
,NETWORK SERVICE
用户
Note: If Above things are not working then try to give same permission toNETWORK
,NETWORK SERVICE
Users
这篇关于共享计算机中服务器上的CreateDirectory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!