[英]MachineKey change does not reflect in web.config
在我的Web应用程序中,管理员可以将验证方法/算法从SHA1更改为HMACSHA256,HMACSHA384等。
在代码中,当我使用ConfigurationManager从web.config中检索值时,它显示为已更新。
但是,当我打开Web.config本身时,该值不会出现在MachineKey部分中。 为什么现在显示?
编辑:我使用的技术是Visual Studio C#和MVC。 以下是web.config的一部分:
<system.web>
<machineKey validationKey="22FEA7D6533FCCE331C2342A1801051F5E2890749CB2D5EF2EEABF8B0D944F389F46FA061D1A203EB75F3A9197914299676917FFD355456CFA0B49CA4C30B348"
decryptionKey="30B2FA2A8C54665E18D9A35E3541BFED6A3E8A640DBA4070" />
<authentication mode="Forms">
<forms name="FormsAuth1" loginUrl="https://localhost/OidcApplication/Oidc/Authenticate" timeout="2880" requireSSL="false" />
</authentication>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
这是我检索机器键值的方法:
machineKeyConfig = (MachineKeySection)GetConfigurationSection("system.web/machineKey");
这就是我设置机器键值的方式:
var machineKeyConfig = (MachineKeySection)GetConfigurationSection("system.web/machineKey");
machineKeyConfig.DecryptionKey = machineKeySettings.DecryptionKey;
machineKeyConfig.Validation = machineKeySettings.Validation;
machineKeyConfig.ValidationKey = machineKeySettings.ValidationKey;
machineKeyConfig.CurrentConfiguration.Save(ConfigurationSaveMode.Minimal);
首先,我将检查您要保存到的文件是否与读取的文件相同:
var ConfigFilePath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
顺便说一句, GetConfigurationSection方法的类和名称空间是什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.