Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在asp.net C中加密连接字符串时出现奇怪的错误#_C#_Asp.net_Encryption_Web Config - Fatal编程技术网

C# 在asp.net C中加密连接字符串时出现奇怪的错误#

C# 在asp.net C中加密连接字符串时出现奇怪的错误#,c#,asp.net,encryption,web-config,C#,Asp.net,Encryption,Web Config,我想在发送源代码以供查看时对连接字符串进行加密。因此,我在Global.asax文件中执行类似的操作 void Application_Start(object sender, EventArgs e) { // Code that runs on application startup EncryptConnString(); } public static void EncryptConnString() { Configuration config = S

我想在发送源代码以供查看时对连接字符串进行加密。因此,我在
Global.asax
文件中执行类似的操作

void Application_Start(object sender, EventArgs e) 
{
    // Code that runs on application startup
       EncryptConnString();
}

public static void EncryptConnString()
{
    Configuration config = System.Web.Configuration
                                     .WebConfigurationManager
                                     .OpenWebConfiguration("~");

    ConfigurationSection section = config.GetSection("connectionStrings");

    if (!section.SectionInformation.IsProtected)
    {
        section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
        config.Save();
    }
}
但是在这一行
config.Save()我得到一些奇怪的错误,如下所示

System.Configuration.dll中出现“System.Configuration.ConfigurationErrorsException”类型的异常,但未在用户代码中处理

其他信息:执行ConnectionString的配置节处理程序时出错


我找不到它的原因,因为它是标准代码加密它。请说明可能的原因

我相信您没有正确设置连接字符串的加密。请考虑这个答案-> @ Aristos:什么样的设置?我在前面的答案上添加了一个链接,有详细信息…@Aristos:现在我知道了,但是在哪里添加这个部分,它将授予我访问该类的权限
aspnet\u regiis-pa“NetFrameworkConfigurationKey”“{domain}\{user}”
??