作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 C# 代码中设置 IP 地址和域限制,我正在关注 this文章,但它给了我无法识别的位置错误。
Error: Unrecognized configuration path 'MACHINE/WEBROOT/APPHOST/websiteName
我的代码:
using (var serverManager = new ServerManager())
{
var config = serverManager.GetApplicationHostConfiguration();
var ipSecuritySection = config.GetSection("system.webServer/security/ipSecurity", "websiteName");
var ipSecurityCollection = ipSecuritySection.GetCollection();
var addElement = ipSecurityCollection.CreateElement("add");
addElement["ipAddress"] = @"SomeIP";
addElement["allowed"] = false;
ipSecurityCollection.Add(addElement);
var addElement1 = ipSecurityCollection.CreateElement("add");
addElement1["ipAddress"] = @"SomeIP";
addElement1["subnetMask"] = @"255.255.0.0";
addElement1["allowed"] = false;
ipSecurityCollection.Add(addElement1);
serverManager.CommitChanges();
}
在这一行之后它给我错误:
var ipSecuritySection = config.GetSection("system.webServer/security/ipSecurity", "websiteName");
谁能告诉我哪里出了问题,或者我遗漏了什么。
最佳答案
您可能会为 IIS/IIS Express 获取损坏的 applicationHost.config,其中网站没有根应用程序。如果您不知道如何编辑它,请发布 <sites>
在问题中标记您的文件,以便其他人可以查看并建议如何修复。
关于c# - IIS 错误 : Unrecognized configuration path 'MACHINE/WEBROOT/APPHOST/websiteName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44133547/
我正在尝试在 C# 代码中设置 IP 地址和域限制,我正在关注 this文章,但它给了我无法识别的位置错误。 Error: Unrecognized configuration path 'MACHI
我正在使用 express.js 框架在 heroku 上运行 node.js 服务器。 这是我的服务器的样子: var express = require('express'); var app =
我是一名优秀的程序员,十分优秀!