我在我的 Web.config 文件中为 asp.net mvc Web 应用程序添加了以下设置
<appSettings>
//code goes here
<add key="ApiUserName" value="testuser" />
<add key="ApiPassword" value=,,,… />
<add key="ApiURL" value="http://win-spdev:8400/servlets/AssetServlet" />
</appSettings>
这些设置用于在我的 Controller 操作方法中启动 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的链接。但我不确定如何在上述操作方法中进行链接中描述的加密和解密?