c# - Web.confg 问题多用户访问
问题描述
当多个用户同时访问 web.config 文件时,这会导致问题,错误表明该文件正在被另一个进程使用
var config = ConfigurationManager.OpenExeConfiguration(string.Empty);
var section = config.GetSection(configSectionName);
// If the section exists and it is not protected
if (section != null && !section.SectionInformation.IsProtected)
{
// Get the name of the default provider
var pcs = (ProtectedConfigurationSection)config.GetSection("configProtectedData");
var provider = pcs.DefaultProvider;
// Apply the provider to the section and save
section.SectionInformation.ProtectSection(provider);
config.Save();
}
解决方案
推荐阅读
- swift - 如何在导航栏中的标题下放置分段控件(如 Telegram App)
- google-analytics - 谷歌分析新用户是否受回溯期影响?
- java - 在运行时编译java文件
- java - 如何使用特定的 JRE 执行 jarsigner
- c - 运算符在while循环中的工作(c编程)
- css - 如何设置引导文本的大小和卡片大小
- jetbrains-ide - PhpStorm 中的 setter 中的 camelCase 参数
- chatbot - Rasa 网络聊天集成
- java - 在 JMeter 中递归列出文件夹和子文件夹中的文件
- redis - Ansible:不同主机的配置文件中相同变量的不同值