943,850 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 3162
  • ASP.NET RSS
Apr 22nd, 2009
0

why is this config file wrong

Expand Post »
Hi,

I wish to add the following to my web.config file:

ASP.NET Syntax (Toggle Plain Text)
  1. <appSettings>
  2. <add key="networkDrive" value="C:\test"/>
  3. </appSettings>
But everytime I add it i get the following error:

ASP.NET Syntax (Toggle Plain Text)
  1. Sections must only appear once per config file
I looked in the file to see if it appeared more than once but couldn't find it I did a search for appSettings it returned three results, two were included in the statement I just added and the third was

ASP.NET Syntax (Toggle Plain Text)
  1. </sectionGroup></sectionGroup></sectionGroup></configSections>
  2.  
  3. <appSettings/>

However I cant see where it was opened. If I take out the code I add the project compiles without error. Please help whole config file below!


ASP.NET Syntax (Toggle Plain Text)
  1. <?xml version="1.0"?>
  2. <!--
  3. Note: As an alternative to hand editing this file you can use the
  4. web admin tool to configure settings for your application. Use
  5. the Website->Asp.Net Configuration option in Visual Studio.
  6. A full list of settings and comments can be found in
  7. machine.config.comments usually located in
  8. \Windows\Microsoft.Net\Framework\v2.x\Config
  9. -->
  10. <configuration>
  11. <configSections>
  12. <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  13. <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  14. <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
  15. <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  16. <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
  17. <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
  18. <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
  19. <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections>
  20.  
  21. <appSettings/>
  22. <connectionStrings>
  23. <add name="sitehealthConnectionString" connectionString="Data Source=CHRIS-LAPTOP\PROJECT;Initial Catalog=sitehealth;Integrated Security=True" providerName="System.Data.SqlClient"/>
  24. </connectionStrings>
  25. <appSettings>
  26. <add key="networkDrive" value="C:\test"/>
  27. </appSettings>
  28. <system.web>
  29. <authentication mode="Windows"/>
  30. <authorization>
  31. <deny users="?"/>
  32. </authorization>
  33. <identity impersonate="true" userName="service_sitehealth" password="VFK279"/>
  34. <!--
  35. Set compilation debug="true" to insert debugging
  36. symbols into the compiled page. Because this
  37. affects performance, set this value to true only
  38. during development.
  39. -->
  40. <compilation debug="true">
  41. <assemblies>
  42. <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  43. <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  44. <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  45. <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  46. <add assembly="System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  47. <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  48. <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  49. <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  50. <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
  51. </compilation>
  52. <!--
  53. The <customErrors> section enables configuration
  54. of what to do if/when an unhandled error occurs
  55. during the execution of a request. Specifically,
  56. it enables developers to configure html error pages
  57. to be displayed in place of a error stack trace.
  58.  
  59. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
  60. <error statusCode="403" redirect="NoAccess.htm" />
  61. <error statusCode="404" redirect="FileNotFound.htm" />
  62. </customErrors>
  63. -->
  64. <pages buffer="true" enableViewState="true">
  65. <controls>
  66. <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  67. <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls></pages>
  68. <httpHandlers>
  69. <remove verb="*" path="*.asmx"/>
  70. <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  71. <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  72. <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpHandlers>
  73. <httpModules>
  74. <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpModules>
  75. </system.web>
  76.  
  77. <system.codedom>
  78. <compilers>
  79. <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
  80. <providerOption name="CompilerVersion" value="v3.5"/>
  81. <providerOption name="WarnAsError" value="false"/></compiler>
  82. <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
  83. <providerOption name="CompilerVersion" value="v3.5"/>
  84. <providerOption name="OptionInfer" value="true"/>
  85. <providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>
  86. <system.webServer>
  87. <validation validateIntegratedModeConfiguration="false"/>
  88. <modules>
  89. <remove name="ScriptModule"/>
  90. <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules>
  91. <handlers>
  92. <remove name="WebServiceHandlerFactory-Integrated"/>
  93. <remove name="ScriptHandlerFactory"/>
  94. <remove name="ScriptHandlerFactoryAppServices"/>
  95. <remove name="ScriptResource"/>
  96. <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  97. <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  98. <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></handlers></system.webServer>
  99. <runtime>
  100. <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  101. <dependentAssembly>
  102. <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
  103. <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>
  104. <dependentAssembly>
  105. <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
  106. <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime></configuration>
Similar Threads
Reputation Points: 38
Solved Threads: 15
Posting Pro in Training
chris5126 is offline Offline
412 posts
since Feb 2006
Apr 22nd, 2009
0

Re: why is this config file wrong

Quote ...
<appSettings/>
Quote ...
<!-- other stuff here... -->
Quote ...
<appSettings>
<add key="networkDrive" value="C:\test"/>
</appSettings>
This is what is wrong. You have two appSettings sections: an empty one (the above) and your modified one. You should keep only one of them.
If you find this answer satisfactory, please add to my reputation.
Last edited by achristov; Apr 22nd, 2009 at 8:38 am.
Reputation Points: 23
Solved Threads: 6
Junior Poster in Training
achristov is offline Offline
68 posts
since Mar 2008
Apr 22nd, 2009
0

Re: why is this config file wrong

Thats what i thought initally but if you look there is never <appSettings> for the first one otherwise I would have just added my key to that section!
Reputation Points: 38
Solved Threads: 15
Posting Pro in Training
chris5126 is offline Offline
412 posts
since Feb 2006
Apr 22nd, 2009
0

Re: why is this config file wrong

Nevermind! You still have two appConfig sections. The fact that the first one does not have child nodes does not mean that the sections are getting merged or otherwise processed by the configuration manager. Once it encounters the first section it processes it and decides that the job's finished. You offer it extra work with the second section so it complains.
Last edited by achristov; Apr 22nd, 2009 at 9:03 am.
Reputation Points: 23
Solved Threads: 6
Junior Poster in Training
achristov is offline Offline
68 posts
since Mar 2008
Apr 22nd, 2009
0

Re: why is this config file wrong

hi,

Thanks and I understand that but how do i fix the problem if I add:

<add key="networkDrive" value="C:\test"/>

Before the <appSettings/> I get an error Unrecognized configuration section add. if I add

<appSettings>
<add key="networkDrive" value="C:\test"/>

I get The 'appSettings' start tag on line 20 does not match the end tag of 'configuration'. Line 106, position 123.

I just dont get it!
Reputation Points: 38
Solved Threads: 15
Posting Pro in Training
chris5126 is offline Offline
412 posts
since Feb 2006
Apr 22nd, 2009
0

Re: why is this config file wrong

You should have
Quote ...
<appSettings><add key="networkDrive" value="C:\test"/></appSettings>
in your web.config. The line
Quote ...
<add key="networkDrive" value="C:\test"/>
is allowed only within appSettings section. The section appSettings should be one and only one in the whole config file.
Reputation Points: 23
Solved Threads: 6
Junior Poster in Training
achristov is offline Offline
68 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Update Web.config from windows application
Next Thread in ASP.NET Forum Timeline: How to write same query for MySql and SqlServer





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC