请帮助,我不知道如何在 ASP.NET 中使用加密的 ConnectionString 和 RoleManager这是 Web.config 中的代码。
<connectionStrings>
<add name="strConnectionString" connectionString="eF8w9r2UJOsk0Ps3pxmV7/Fy/xPR2hN2S7BrC1iOYNnAUaI8AqkSm5bw7r+ta4sePWSV9t/3Spnpz6wsFpvMmcppNpqM5Zk7iiDqWVgIV4k="/>
</connectionStrings>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add connectionStringName="strConnectionString" name="CustomizedRoleProvider" type="System.Web.Security.SqlRoleProvider" />
</providers>
</roleManager>
<membership defaultProvider="CustomizedMembershipProvider">
<providers>
<add connectionStringName="strConnectionString" name="CustomizedMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>
</providers>
</membership>
在项目中,我创建了一个库来读取网络配置
private const string ConnectionStringKey = "strConnectionString";
private readonly string SQLConnectionString =
Security.DecryptString(ConfigurationManager.ConnectionStrings[ConnectionStringKey].ConnectionString);
如果我像这样更改我的 ConnectionString,它正在工作:
<add name="strConnectionString" connectionString="server=My-PC\\MSSQL2008; database=MyDB; uid=sa; pwd=passw0rd;"/>
但我希望我的 ConnectionString 加密所以我使用
<add name="strConnectionString" connectionString="eF8w9r2UJOsk0Ps3pxmV7/Fy/xPR2hN2S7BrC1iOYNnAUaI8AqkSm5bw7r+ta4sePWSV9t/3Spnpz6wsFpvMmcppNpqM5Zk7iiDqWVgIV4k="/>
所以当我运行网站时,它会抛出错误:
System.ArgumentException:Keyword not supported: 'eF8w9r2UJOsk0Ps3pxmV7/Fy/xPR2hN2S7BrC1iOYNnAUaI8AqkSm5bw7r+ta4sePWSV9t/3Spnpz6wsFpvMmcppNpqM5Zk7iiDqWVgIV4k='.
Line 46: string[] roleNames;
Line 47: roleNames = Roles.GetAllRoles();
任何人帮助我找出它或任何建议?