asp.net-mvc - appcmd 无法添加类型为“add”且唯一键属性“文件扩展名”设置为“.txt”的重复集合条目
问题描述
试图通过 appcmd 允许 IIS 中的特定文件类型。使用此代码:
appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"fileExtensions.[fileExtension='.txt',allowed='True']"
如果文件扩展名已在 IIS 中列出允许或拒绝,我会收到此错误:
cannot add duplicate collection entry of type 'add' with unique key attribute 'file extension' set to '.txt'
我想我需要先删除 IIS 中的特定文件扩展名允许/拒绝规则,然后再将它们添加回来,但我不知道如何通过 appcmd 执行此操作。
解决方案
Use this to add specific file types:
appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"fileExtensions.[fileExtension='.txt']"
Use this to remove specific file types:
appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /-"fileExtensions.[fileExtension='.txt']"
推荐阅读
- python - 如何在另一个文件中使用调用文件循环变量(python)
- android - ScrollView 在约束布局中不起作用
- c# - 将一排对象统一创建一个新的游戏对象
- union - 如何使用 UNION 并按特定选择排序?
- c# - 如何针对本地 ADFS 对用户进行身份验证
- tensorflow - 如何创建自己的联合数据集并使用 TensorflowFederated 在多个设备上进行学习?
- macos - 如何在 Catalina 的自动外观模式下检测 OSX 是处于暗模式还是亮模式
- ruby - 从文件运行 s 表达式
- php - 无法发送 SMTP 邮件 PHPMailer
- typescript - 如何在新的 gulp 任务 api 中使用旧式任务名称?