且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

由于权限不足,无法读取配置文件

更新时间:2022-05-13 23:36:27

您的 web.config 没有问题.您的网站在一个进程下运行.在 iis 中,您可以定义该进程的身份.您网站的应用程序池所运行的身份(网络服务、本地系统等)应具有访问和读取网络的权限.config 文件.

There is no problem with your web.config. Your web site runs under a process. In iis you can define the identity of that process. The identity that your web site's application pool runs as (Network Services, Local System, etc.), should have permission to access and read web.config file.

更新:

这个更新后的答案与上面的相同,但更长、更简单并有所改进.

首先:您不必更改配置文件中的任何内容.没关系.问题在于 Windows 文件权限.

First of all: you don't have to change anything in your config file. It's OK. The problem is with windows file permissions.

出现此问题是因为您的应用程序无法访问读取 web.config 文件.

This problems occurs because your application can not access and read web.config file.

使 IIS_IUSRS 组可以访问该文件.只需右键单击 web.config 并单击 properties,在 security 选项卡下,添加 IIS_IUSRS.

Make the file accessible to IIS_IUSRS group. Just right click web.config and click properties, under security tab, add IIS_IUSRS.

那么这个 IIS_IUSRS 是什么东西?

So what is this IIS_IUSRS thing?

您的网站就像一个exe文件.就像任何 exe 文件一样,它应该由用户启动,并根据分配给该用户的权限运行.

Your web site is like an exe file. Just like any exe file, it should be started by a user and it runs according to permissions assigned to that user.

当您的网站在 IIS 中启动时,您网站的应用程序池会与用户(网络服务、本地系统,等等...)(并且可以在 IIS 中更改)

When your site is started in IIS, Application Pool of your web site is associated with a user (Network Services, Local System, Etc. ...) (and can be changed in IIS)

所以当您说 IIS_IUSRS 时,它意味着您的网站任何用户(网络服务、本地系统等...)正在运行.

So when you say IIS_IUSRS, it means any user (Network Services, Local System, Etc. ...) that your site is running as.

正如 @Seph下面的评论中提到的:如果您的计算机在域中,请记住IIS_IUSRS 组是一个本地组.还要确保在您尝试查找此用户时检查应将其设置为本地计算机而不是公司域的位置.

And as @Seph mentioned in comment below: If your computer is on a domain, remember that IIS_IUSRS group is a local group. Also make sure that when you're trying to find this user check the location it should be set to local computer and not a corporate domain.