配置错误:无法在此路径上使用此配置部分

在将网站部署到服务器时遇到一个错误,当尝试加载主页或访问IIS中的身份验证时,显示配置错误:无法在此路径上使用此配置部分。错误源于配置部分在父级被锁定。解决方案包括修改applicationHost.config文件中的overrideModeDefault属性,使用IIS管理器编辑设置,启用IIS功能,解锁处理程序,或确保操作正确的配置文件。
摘要由CSDN通过智能技术生成

本文翻译自:Config Error: This configuration section cannot be used at this path

I've encountered an error deploying a site to a server. 将网站部署到服务器时遇到错误。 When trying to load the home page, or access authentication on the new site in IIS, I get the error: 尝试加载主页或访问IIS中新站点上的身份验证时,出现错误:

Config Error: This configuration section cannot be used at this path. 配置错误:无法在此路径上使用此配置部分。 This happens when the section is locked at a parent level. 当节锁定在父级时,会发生这种情况。 Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false". 锁定默认情况下是(overrideModeDefault =“ Deny”),或者是由一个带有overlayMode =“ Deny”或旧版allowOverride =“ false”的位置标记显式设置的。

More detail can be found here, in Scenario 7 matches my hex error code. 方案7中匹配我的十六进制错误代码,可以在这里找到更多详细信息。

The solution given on the linked site above is to set Allow for overrideModeDefault in the section mentioned in my error, in the applicationHost.config file. 上面的链接站点上给出的解决方案是在我的错误中提到的部分中,在applicationHost.config文件中设置Allow for overlayModeDefault。 In my case, under Security in system.webServer . 就我而言,位于system.webServer中的 Security下。 But if I look at the applicationHost.config on my local computer, where the site is properly deployed already, that section is set to Deny . 但是,如果我查看本地计算机上已经正确部署了站点的applicationHost.config ,则该部分设置为Deny

If this solution is correct, how is my local instance running just fine with the same web.config ? 如果此解决方案正确,那么我的本地实例如何在相同的web.config下正常运行? According to my applicationHost.config , that section should be locked, but it's not. 根据我的applicationHost.config ,该部分应被锁定,但不是。 I'd prefer to not change the applicationHost.config file, because there are many other sites running on that server. 我希望不要更改applicationHost.config文件,因为该服务器上还有许多其他站点正在运行。 Is there another solution? 还有其他解决方案吗?


#1楼

参考:https://stackoom.com/question/f67d/配置错误-无法在此路径上使用此配置部分


#2楼

Browse to “C:\\Windows\\System32\\inetsrv\\config” (you will need administrator rights here) Open applicationHost.config 浏览到“ C:\\ Windows \\ System32 \\ inetsrv \\ config”(您将在此处需要管理员权限)打开applicationHost.config

Note : In IISExpress and Visual Studio 2015 the applicationHost.config is stored in $(solutionDir).vs\\config\\applicationhost.config 注意 :在IISExpress和Visual Studio 2015中,applicationHost.config存储在$(solutionDir).vs\\config\\applicationhost.config

Find the section that showed up in the “config source” part of the error message page. 找到错误消息页面的“配置源”部分中显示的部分。 For me this has typically been “modules” or “handlers” 对我来说,这通常是“模块”或“处理程序”

Change the overrideModeDefault attribute to be Allow overrideModeDefault属性更改为Allow

So the whole line now looks like: 所以整行现在看起来像:

<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />

After saving the file, the page loaded up fine in my browser. 保存文件后,页面在我的浏览器中正常加载。

Warning: Editing applicationHost.config on 64-bit Windows 警告: 在64位Windows上编辑applicationHost.config


#3楼

You could also use the IIS Manager to edit those settings. 您也可以使用IIS管理器来编辑那些设置。

Care of this Learn IIS article : 这篇学习IIS文章的内容

Using the Feature Delegation from the root of IIS: 从IIS的根目录使用功能委托

IIS管理器中的功能委派图标

You can then control each of machine-level read/write permissions, which will otherwise give you the overrideMode="Deny" errors. 然后,您可以控制每个计算机级别的读/写权限,否则将给您overrideMode =“ Deny”错误。

功能委托的使用示例


#4楼

I had the same problem. 我有同样的问题。 Don't remember where I found it on the web, but here is what I did: 不记得我在网上找到的位置了,但这是我做的:

  • Click "Start button" 点击“开始按钮”
  • in the search box, enter "Turn windows features on or off" 在搜索框中,输入“打开或关闭Windows功能”
  • in the features window, Click: "Internet Information Services" 在功能窗口中,单击:“ Internet信息服务”
  • Click: "World Wide Web Services" 单击:“万维网服务”
  • Click: "Application Development Features" 单击:“应用程序开发功能”
  • Check (enable) the features. 检查(启用)功能。 I checked all but CGI. 我检查了所有,但CGI。

btw, I'm using Windows 7. 顺便说一句,我正在使用Windows 7。


#5楼

You need to unlock handlers. 您需要解锁处理程序。 This can be done using following cmd command: 可以使用以下cmd命令完成此操作:

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers

Maybe another info for people that are getting this error on IIS 8, in my case was on Microsoft Server 2012 platform. 对于在IIS 8上出现此错误的人来说,也许是另一个信息,在我的情况下是在Microsoft Server 2012平台上。 I had spend couple of hours battling with other errors that bubbled up after executing appcmd. 我花了几个小时来应对执行appcmd之后冒出来的其他错误。 In the end I was able to fix it by removing Web Server Role and installing it again. 最后,我能够通过删除Web服务器角色并再次安装来修复它。


#6楼

In my case, I got this error because I was operating on the wrong configuration file. 就我而言,出现此错误是因为我在错误的配置文件上进行操作。

I was doing this: 我正在这样做:

Configuration config = serverManager.GetWebConfiguration(websiteName);
ConfigurationSection serverRuntimeSection = config.GetSection("system.webServer/serverRuntime");
serverRuntimeSection["alternateHostName"] = hostname;

instead of the correct code: 而不是正确的代码:

Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection serverRuntimeSection = configApp.GetSection("system.webServer/serverRuntime", websiteName);
serverRuntimeSection["alternateHostName"] = hostname;

in other words, I was trying to operate on the website's web.config instead of the global file C:\\Windows\\System32\\inetsrv\\config\\applicationHost.config, which has a section (or can have a section) for the website. 换句话说,我试图在网站的web.config上而不是在全局文件C:\\ Windows \\ System32 \\ inetsrv \\ config \\ applicationHost.config上进行操作,该文件具有网站的一部分(或可以有一部分)。 The setting I was trying to change exists only in the applicationHost.config file. 我尝试更改的设置仅存在于applicationHost.config文件中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值