2009-12-03 18 views
0

無法理解爲什麼這個工作原理在web(改用WebConfigManager)而不是winapp.When我看看配置文件仍然沒有加密!我錯過了什麼? 你能幫忙嗎?無法加密winforms中的連接字符串,但在web中工作嗎?mmm你能幫忙

EncryptionUtility.ProtectSection("connectionStrings", "DataProtectionConfigurationProvider"); 

public class EncryptionUtility 
    { 
     public static void ProtectSection(string sectionName,string provider) 
     { 
      var config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath); 

      var section = config.GetSection(sectionName); 

      if (section == null || section.SectionInformation.IsProtected) return; 
      section.SectionInformation.ProtectSection(provider); 
      config.Save(); 
     } 

     public static void UnProtectSection(string sectionName) 
     { 
      var config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath); 

      var section = config.GetSection(sectionName); 

      if (section == null || !section.SectionInformation.IsProtected) return; 
      section.SectionInformation.UnprotectSection(); 
      config.Save(); 
     } 
    } 

回答

0

在的WinForms,你有3個配置文件:一個項目,在調試目錄中,一個在版本目錄。你確定你試圖加密正確的嗎?

+0

愚蠢的問題我怎麼知道我正在加密哪一個? – 2009-12-03 21:00:57

+0

一個臨近執行的exe文件,名爲 2009-12-03 21:07:01

相關問題