为什么我仍然得到“访问路径'C:\ ... \ ...'被拒绝”甚至在授予该目录的IIS_IUSRS写权限后? [英] Why am I still getting "Access to the path 'C:\...\...' is denied" even after granting IIS_IUSRS write permission on the directory?

查看:219
本文介绍了为什么我仍然得到“访问路径'C:\ ... \ ...'被拒绝”甚至在授予该目录的IIS_IUSRS写权限后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的控制器上编写了一个方法,为我的客户端自动生成一个powerpoint卡座,所有这些都可以正常工作......除了我关于将文件保存到磁盘的部分。

I've written a method on my controller that auto generates a powerpoint deck for my client and all that works fine...except I'm stuck on the part about saving the file to disk.

我对这个概念并不陌生;并且认为我需要做的就是授予IIS_IUSRS对目录的写权限以及对所有父目录的读权限。我正在使用IIS 7,之前我已经使用IIS 6授予NETWORK SERVICE相同的权限。

I'm no stranger to this concept; and "thought" that all I needed to do is grant IIS_IUSRS write permission on the directory and read permission on all parent directories. I'm using IIS 7, and I've done this before with IIS 6 granting NETWORK SERVICE the same permissions.

只是为了踢,我甚至给了每个人对该目录的写权限,我仍然不断得到异常:System.UnauthorizedAccessException:访问路径'C:... ...... \Content\PPT'被拒绝。 (为了简单起见,我删除了一些路径。)

Just for kicks, I even gave EVERYONE write permissions on the directory and I still keep getting the Exception: System.UnauthorizedAccessException: Access to the path 'C:......\Content\PPT' is denied. (I removed some of the path for simplicity).

还有什么我可以忽略的吗?它所在的服务器是我设置的第一个,所以我可能忽略了一些东西?

Is there anything else I am overlooking? The server it's on is the first one I've set up, so I just may have overlooked something?

这是我的控制器方法简化:

Here's my controller method simplified:

public ActionResult CreatePowerPoint()
    {
        string path = HttpContext.Server.MapPath("~/Content/PPT");

        Aspose.Slides.Presentation presentation = new Aspose.Slides.Presentation();
        CreatePresentation(presentation);

        presentation.Save(path, Aspose.Slides.Export.SaveFormat.Ppt);

        return View();
    }
}

presentation.Save()方法采用路径保存格式...我不知道还有什么可以尝试...我的代码有问题吗?我是否错误地创建了路径?我也可以将Stream流传递给save方法,但我不确定是否能解决问题。

the presentation.Save() method takes a path and a save format...I don't know what else to try... Is there something wrong with my code? Am I creating the path incorrectly? I can also pass a Stream stream into the save method, but I am not sure if that will fix the problem.

推荐答案

我找到了解决方案 - 我正在使用IIS 7,并且我将应用程序池设置为错误的标识。在IIS 7中,我只是更改了我的应用程序运行的应用程序池的标识和繁荣,一切正常。我使用NETWORK SERVICE作为我的身份。

I found the solution - I'm using IIS 7, and I had the application pool set to the wrong identity. In IIS 7, I simply changed the identity of the application pool my app is running on and boom, everything worked. I used NETWORK SERVICE as my identity.

对于那些使用Aspose幻灯片的人,我还必须确保文件名在路径中。

Also for those using Aspose Slides, I also had to make sure the file name was in the path.

这篇关于为什么我仍然得到“访问路径'C:\ ... \ ...'被拒绝”甚至在授予该目录的IIS_IUSRS写权限后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆