如题

解决方案 »

  1.   

    帮助:System.Configuration
    其实web.config是一个xml文件,通过System.Xml.XmlDocument 来操作可以任意修改。
      

  2.   

    //web.config修改appSettings;
    public void Modify(string key,string strValue)                                            //两个参数:要修改的键值 和 要修改的新值;              
    {
    string XPath="/configuration/appSettings/add[@key='?']";                              
    XmlDocument domWebConfig=new XmlDocument();
       
    domWebConfig.Load( (HttpContext.Current.Server.MapPath("web.config")) );
    XmlNode addKey=domWebConfig.SelectSingleNode( (XPath.Replace("?",key)) );
    if(addKey == null)
    {
    //throw new ArgumentException("没有找到<add key='"+key+"' value=.../>的配置节");
    Response.Write("<script>alert (\"没有找到<add key='"+key+"' value=.../>的配置节\")</script>");
    return;
    }
    addKey.Attributes["value"].InnerText=strValue;
    domWebConfig.Save( (HttpContext.Current.Server.MapPath("web.config")) );
       
    }
      

  3.   

    操作XML就可以了,不过最好不要这样做,否则Session将丢失
      

  4.   

    我倒是操作过.不过操作要重新登陆..因为默认全部丢失了!~
    就是读写XML文件的东西!~很,简单