由于项目需要,把Web.config中的部分节点进行了转移,如:identity,System.serviceModle,SectionGroup..等节点
在Application_Start中操作Xml节点的方式动态添加了这些转移掉的节点。这样虽然Web.config中这些节点也写入了,但是每次重启IIS后,我们读取到的节点值往往是上一次Web.config中的值,新写入的节点值获取不到。疑问:
为啥WinForm项目中可以这样操作(值已经取到)?为啥用ConfigurationManager.RefreshSection 方法强制刷新这些节点,还是取不到值?
请问有不改解决方案,就可以实现的方法吗?(暂时不想改成ConfigurationManager类动态操作Web.config节点的方案)

解决方案 »

  1.   

    修改config重启Web应用程序
    ServiceController sc = new ServiceController("iisadmin");   
    sc.Start();HttpRuntime.UnloadAppDomain();
      

  2.   

    自己新建一个xml文件来操作你要的东西,不要对web.config操作,会引起IIS重启的。
      

  3.   

    虽然Web.config中这些节点也写入了?你保证写的位置对了?写完之后Save进去了吗?
    修改web.config会自动重启的,无需执行代码
      

  4.   

    我Save()了,Web.config写入也正确
      

  5.   

    被拒绝了: Access is denied
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
      

  6.   

    修改Web.config文件后
    在.aspx页面中 HttpRuntime.UnloadAppDomain(); 可以获取到其中的值
    但是在Application_start中修改了Web.config用这种方式为啥刷新不了期待高手的出现!!!!