郁闷好几天,问个小菜的问题
我的网站配置(web.config)如下:
<?xml version= "1.0 "?>
<configuration>
<location path= "recivpwd.aspx ">
<system.web>
</system.web>
</location>
<location path= "css/style3.css ">
<system.web>
<authorization>
</authorization>
</system.web>
</location>
<appSettings>
<add key= "connectionstring " value= "server=(local);database=diarybook;uid=sa;pwd= " />
</appSettings>
<system.web>
<httpHandlers>
<add verb= "GET " path= "FtbWebResource.axd " type= "FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox " />
</httpHandlers>
<compilation debug= "true ">
<assemblies>
<add assembly= "System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A " />
</assemblies>
</compilation>
<authentication mode= "Forms ">
<forms name= ".ASPXUSERDEMO " loginUrl= "Login.aspx " defaultUrl= "default.aspx " protection= "All " timeout= "30 " />
</authentication>
<authorization>
<deny users= "? " />
</authorization>
</configuration>
[解决办法]
xmldoc.DocumentElement.ChildNodes[3].ChildNodes[3].RemoveAll();
xmldoc.DocumentElement.ChildNodes[3].SelectSingleNode( "authorization ").RemoveAll();
这两种方法都可以删除authorization的所有子节点。
另外, xmldoc.save(confile);这一行,应该为 xmldoc.Save(confile);