首页 > 解决方案 > 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();
}

标签: c#asp.net.netwebweb-config

解决方案


推荐阅读