locked
Sections must only appear once per config file. See the help topic <location> for exceptions. RRS feed

  • Question

  • User-126838039 posted

    Hi , im getting error as : 

    Sections must only appear once per config file. See the help topic <location> for exceptions. 

    web.config 61 0 VehicleSystem.UI

    following is my web.config code :

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <appSettings>
        <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
      </appSettings>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
          <remove name="ChartImageHandler" />
          <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
            path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </handlers>
      </system.webServer>
      <system.web>
        <httpHandlers>
          <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            validate="false" />
        </httpHandlers>
        <pages>
          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
              assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          </controls>
        </pages>
        <machineKey validationKey="ACBB0668C27E1A69F64CB579AD5333C4A37F72365A91499DAD045EF1C51CC5C7E551A10A9B65BE6EDF86F9FB569D32F6C4EFB0E933D38B3BE954D615865B599D" decryptionKey="E9CE6A4F1E788B5AF35A42848C32DCF300555F00E4A7B700F3CB524576319844" validation="SHA1" decryption="AES" />
        <compilation targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>
        <membership defaultProvider="AspNetSqlMembershipProvider1">
          <providers>
            <add name="AspNetSqlMembershipProvider1" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="dfconn" enablePasswordRetrieval="true" enablePasswordReset="false" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="true" passwordFormat="Encrypted" maxInvalidPasswordAttempts="20" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordStrengthRegularExpression="" />
          </providers>
        </membership>
        <roleManager enabled="true" defaultProvider="SqlRoleManager">
          <providers>
            <clear />
            <add name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="dfconn" />
          </providers>
        </roleManager>
        <httpRuntime />
        <authentication mode="Forms">
          <forms loginUrl="~/user/login.aspx" timeout="30" />
        </authentication>
      </system.web>
      <connectionStrings>
        <add name="VehicleManagerContainer" connectionString="metadata=res://*/VehicleManager.csdl|res://*/VehicleManager.ssdl|res://*/VehicleManager.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SHAN\SHAN;initial catalog=VehicleManager;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <add name="dfconn" connectionString="Data Source=SHAN\SHAN;Initial Catalog=VehicleManager;User ID=sa;Password=123" providerName="System.Data.SqlClient" />
      </connectionStrings>
      <location path="vehicle">
        
        <system.web>
          <authorization>
            <allow roles="admin" />
            <deny users="*" />
          </authorization>
        </system.web>
      </location>
      <location path="receipt">
        <system.web>
          <authorization>
            <allow roles="managers" />
            <allow roles="admin" />
            <deny users="*" />
          </authorization>
        </system.web>
      </location>
      <location path="sales">
        <system.web>
          <authorization>
            
            <allow roles="admin" />
            <deny users="*" />
          </authorization>
        </system.web>
      </location>
      <location path="settings">
        <system.web>
          <authorization>
            
            <allow roles="admin" />
            <deny users="*" />
          </authorization>
        </system.web>
      </location>
      <location path="vehicle">
        <system.web>
          <authorization>
            
            <allow roles="admin" />
            <deny users="*" />
          </authorization>
        </system.web>
      </location>
      <system.net>
        <mailSettings>
          <smtp from="sadfsafdsafd.com">
            <network defaultCredentials="true" host="asdfasdfds.com" userName="aadsfadf.com" password="testingggggg" />
          </smtp>
        </mailSettings>
      </system.net>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
    </configuration>

    Friday, January 24, 2014 3:43 PM

Answers

  • User1734617369 posted

    Hi,

    You have the following declared twice:

    <location path="vehicle">
        <system.web>
          <authorization>
            <allow roles="admin"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>

    remove one of them and you won't get the error.

    Best regards
    Johan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 24, 2014 3:59 PM
  • User-1454326058 posted

    Hi shan,

    Based on the error message, the reason is the authorization of a path has been defined multiple times.

    However, you said that you still get the error even though the section as valuja said has been removed.

    So, I suggest that first, please try to clean the project and rebuild, then check the result.

    On the other hand, please remove all location sections and add a location after each time succeed test.

    Thanks

    Best Regards  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 27, 2014 1:46 AM

All replies

  • User1734617369 posted

    Hi,

    You have the following declared twice:

    <location path="vehicle">
        <system.web>
          <authorization>
            <allow roles="admin"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>

    remove one of them and you won't get the error.

    Best regards
    Johan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 24, 2014 3:59 PM
  • User-126838039 posted

    i have removed this when still i get this error :

    HTTP Error 500.19 - Internal Server Error

    The requested page cannot be accessed because the related configuration data for the page is invalid.

     Config section 'system.web/authorization' already defined. Sections must only appear once per config file. See the help topic <location> for exceptions

    when i publish the site using file system and check the option for precompile during publishing. i get this error again

    Friday, January 24, 2014 4:38 PM
  • User-1716253493 posted
    I guess because you have 2 locations for vehicle
    Friday, January 24, 2014 6:05 PM
  • User-1454326058 posted

    Hi shan,

    Based on the error message, the reason is the authorization of a path has been defined multiple times.

    However, you said that you still get the error even though the section as valuja said has been removed.

    So, I suggest that first, please try to clean the project and rebuild, then check the result.

    On the other hand, please remove all location sections and add a location after each time succeed test.

    Thanks

    Best Regards  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 27, 2014 1:46 AM