我加入以下设置我的web.config文件中的一个asp.net MVC Web应用程序我怎样才能加密和解密,然后Web.config文件内容
<appSettings>
//code goes here
<add key="ApiUserName" value="testuser" />
<add key="ApiPassword" value=,,,… />
<add key="ApiURL" value="http://win-spdev:8400/servlets/AssetServlet" />
</appSettings>
这些设置用于启动API调用因为按照我的控制器的操作方法中: -
using (var client = new WebClient())
{
var query = HttpUtility.ParseQueryString(string.Empty);
foreach (string key in formValues)
{
query[key] = this.Request.Form[key];
}
query["username"] = System.Web.Configuration.WebConfigurationManager.AppSettings["ApiUserName"];
query["password"] = System.Web.Configuration.WebConfigurationManager.AppSettings["ApiPassword"];
query["assetType"] = "Rack";
query["operation"] = "AddAsset";
string apiurl = System.Web.Configuration.WebConfigurationManager.AppSettings["ApiURL"];
var url = new UriBuilder(apiurl);
我看了一下加密和解密web.config文件http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx下面的链接。但我不知道如何执行tehe链接中描述的加密和解密,在我的上述操作方法中?
的[web.config中加密与解密]可能重复(http://stackoverflow.com/questions/5326695/web-config-encryption-decryption) –