2011-08-23 35 views
1

我想某些鍵添加到我的web.config:web.config文件中缺少一個<appsettings>

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
     <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
       <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
       <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
        <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/> 
        <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
        <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
        <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> 
    <add key="dePracticeErrors" value="agordon,user1,user2,user3"/> 
    <add key="dePreAnalytical" value="user2,user1,user3"/> 
    <appSettings/> 


    <connectionStrings> 
     <add name="qcvalues_testConnectionString" connectionString="Data Source=hermes;Initial Catalog=qcvalues_test;Integrated Security=True" providerName="System.Data.SqlClient"/> 
    </connectionStrings> 
    <system.web> 
     <!-- 

我編譯時出現此錯誤:

Server Error in '/' Application. 

Configuration Error 

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Unrecognized configuration section add. 

Source Error: 


Line 14:  </sectionGroup> 
Line 15: </configSections> 
Line 16: <add key="dePracticeErrors" value="agordon,user1,user2,user3"/> 
Line 17: <add key="dePreAnalytical" value="user2,user1,user3"/> 
Line 18: <appSettings/> 

Source File: C:\Documents and Settings\agordon\My Documents\Visual Studio 2008\Projects\EnterData\EnterData\web.config Line: 16 

Version Information: Microsoft .NET Framework Version:2.0.50727.3623; ASP.NET Version:2.0.50727.3618 

我看到這個配置文件:

<appSettings/>但是我沒有看到一個開放標籤的所有< appSettings>

哪裏是開標籤,爲什麼它不像我的鑰匙?

+0

我已經upvoted @Alexander Kahoun的答案,但這個問題是超越了基本的。這個特定問題的答案很容易在文檔中找到。你應該RTFM。 http://msdn.microsoft.com/en-us/library/ackhksh7(v=vs.71).aspx –

+0

出於好奇,您使用的是什麼版本的ASP.NET? – IrishChieftain

+0

@joel謝謝,你能幫助這個嗎? http://serverfault.com/questions/304166/does-iis-server-have-to-be-on-domain-for-windows-authentication-and-roles –

回答

5
<appSettings/> 

是單行封閉標籤。這意味着你已經聲明瞭appSettings元素,並且你聲明它沒有內容。在上例中,您的密鑰當前是<configuration> root的子節點。

變化:

<add key="dePracticeErrors" value="agordon,user1,user2,user3"/> 
    <add key="dePreAnalytical" value="user2,user1,user3"/> 
    <appSettings/> 

要:

<appSettings> 
    <add key="dePracticeErrors" value="agordon,user1,user2,user3"/> 
    <add key="dePreAnalytical" value="user2,user1,user3"/> 
    </appSettings> 
+0

非常感謝你能幫助這個:http://serverfault.com/questions/304166/does-iis-server-have-to-be-on-domain-for-windows-authentication-and-roles –

+0

很好的答案,恰好幫助初學者 - 我現在是一個。 **'表示您已經聲明瞭appSettings元素,並且您聲明它沒有內容。** – bonCodigo