怎么弄?对Web.Config的节点 进行增加,删除,修改?
解决方案 »
- IIS7.5下运行网页的进程是哪一个?
- Maxtocode加密.net预编译之后的dll
- alert来自网页的消息
- GridView嵌套DropDownList
- checkboxlist实现查询
- 关于repeater控件,按时间先后显示(在线等待)急啊!
- 关于xml的新手问题
- Could not create an environment: OCIEnvCreate returned -1.
- [求救]怎样在程序中实现把EXCEL表格导进指定的表中去?
- 【新手求助】怎么防止Response.Write输出页面的全部html
- 获得图片大小kb
- 我用flashpaper2,把图片转成SWF文件格式的时候,如果图片的宽大于高时,转换完的SWF文件里的图片就变倒了
建議用xml檔案來放你要進行“增、刪、改”的數據。
{
FileInfo fileinfo = new FileInfo(Context.Parameters["targetdir"] + "\\web.config");
if (!fileinfo.Exists)
{
throw new InstallException("没有找到配置文件");
}
XmlDocument xmldocument=new XmlDocument();
xmldocument.Load(fileinfo.FullName);
Boolean FoundIt = false;
foreach(XmlNode node in xmldocument.SelectSingleNode("appSettings").ChildNodes)
{
if (node.Name == "add")
{
if (node.Attributes.GetNamedItem("key").Value == "connString")
{
node.Attributes.GetNamedItem("value").Value= String.Format("Persist Security Info=False;Data Source={0};Initial Catalog={1};User ID={2};Password={3};Packet Size=4096;Pooling=true;Max Pool Size=100;Min Pool Size=1",Context.Parameters["server"],Context.Parameters["dbname"], Context.Parameters["user"], Context.Parameters["pwd"]);
FoundIt= true;
}
}
}
if (!FoundIt)
{
throw new InstallException("web.Config 文件没有包含connString连接字符串设置");
}
xmldocument.Save(fileinfo.FullName);
}
catch(Exception ex)
{
throw ex;
}
}
config 操作
另问:为什么要操作webconfig?是否频繁?
那你的Session 緩存 怎麼辦?