在vs2005以上用
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pdf "节点" "物理路径"
可以加密web.config,也可以正常访问,但在vs2003加密后访问的时候报错,提示"无法识别的属性“configProtectionProvider”
请问各位大哥该怎么解决?

解决方案 »

  1.   

    Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/");
    ConfigurationSection connectionStringsConfigSection = config.ConnectionStrings;
                if (!connectionStringsConfigSection.SectionInformation.IsProtected)
                {
                    connectionStringsConfigSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
                }
      

  2.   

    连接字符串加密解密
    可用aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT AUTHORITY\NETWORK SERVICE" 
    XP下:aspnet_regiis -pa "NetFrameworkConfigurationKey" "aspnet" 
    加密:aspnet_regiis -pe "appSettings" -app "/应用程序名 " 
    解密:aspnet_regiis -pd "appSettings" -app "/应用程序名 
    安全性要求较高应采用SHA1以上的算法