虽然我想尝试在我的项目中暗示它给错误 [英] While i want to try to impliment in my project it giveing error
本文介绍了虽然我想尝试在我的项目中暗示它给错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using System;
using System.Data;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
/// <summary>
/// Summary description for clsEncrypt
/// </summary>
public class clsEncrypt
{
//public clsEncrypt()
//{
//
// TODO: Add constructor logic here
//
//}
public static object webencrypt()
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
//' Write the section name of web.config file (connectionStrings)
ConfigurationSection configSection = config.GetSection("connectionStrings"); ;
//' Check the section of web.config file (connectionStrings) if Protected
//' then UnprotectSection (decrypt) the section
if (configSection.SectionInformation.IsProtected)
{
configSection.SectionInformation.UnprotectSection();
config.Save();
}
else
{
//' Check the section of web.config file (connectionStrings)
//' if UnprotectSection then
//' protect (encrypt) Section the section
configSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
}
return config;
}
}
我想对我的web.config文件进行加密.但是当尝试使用此代码对web.config文件进行加密时,它会给出类似加载配置文件时发生错误:无法映射路径"的错误. "
请有人为我提供良好的解决方案.........
感谢adv.
i want to encrypt my web.config file .But when a''m try to encrypt web.config file using this code it giving errors like "An error occurred loading a configuration file: Failed to map the path ''/''."
please someone provide me good soluation for this ............
thanks in adv.
推荐答案
这可能是因为在运行应用程序(ISS)的上下文中,用户没有足够的权限来更改和/或保存web.config.
This is probably because the user in which context the application runs (ISS) has not enough permission to change and/or save web.config.
这篇关于虽然我想尝试在我的项目中暗示它给错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文