簡體   English   中英

MachineKey更改未反映在web.config中

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM