2016-11-17 63 views
-1

什么是错的这个计划为什么我得到错误xpected XmlNodeType.Element,类型是Wh​​itespace?

var modifiedXML = @" <system.webServer><rewrite><rules><rule name='rule 1D' stopProcessing='false'><match url='^(.*)$'/><!--<action type= 'Rewrite' url='//offline.html'/>--></rule></rules></rewrite></system.webServer>"; 
      var configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");   
      var section = configuration.GetSection("system.webServer"); 
      section.SectionInformation.SetRawXml(modifiedXML); 
      configuration.Save(); 

错误:

An exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll but was not handled in user code

Additional information: expected XmlNodeType.Element, type is Whitespace.

回答

3

试图改变

var modifiedXML = @" <system.webServer>... 

var modifiedXML = @"<system.webServer>... 

(根元素之前的不必要空间)。

+0

非常感谢....我会很快接受你的。 –