Search code examples
asp.netasp.net-web-apiweb-config

Please indicate the preferred endpoint configuration section by name


Before some one commenting that it is a duplicate, please note that i have gone through the suggestions given in internet.

Scenario:

I am having a web api call and have only one end point in the webconfig`

 <client>
           <endpoint address="http://localhost/RegistrationService/RegistrationService.svc"
        binding="basicHttpBinding" bindingConfiguration="RegistrationService"
        contract="RegistrationService.IRegistrationService" name="RegistrationService" />
      <endpoint address="http://localhost/ElectronicCustomerFileService/ElectronicCustomerFileService.svc"
        binding="basicHttpBinding" bindingConfiguration="ElectronicCustomerFileService"
        contract="ElectronicCustomerFileService.IElectronicCustomerFileService"
        name="ElectronicCustomerFileService" />
    </client>

`

following is the binding equivalent

`

 <bindings>
      <basicHttpBinding>
        <binding name="RegistrationService" maxBufferPoolSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
        </binding>
        <binding name="ElectronicCustomerFileService" />
      </basicHttpBinding>
    </bindings>

`

While i run the application i am getting error

An endpoint configuration section for contract 'ElectronicCustomerFileService.IElectronicCustomerFileService' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

Tools Used

I am using Visual studio 2017 . I had Visual Studio 2019 and uninstalled it thinking that the issue is due to visual studio version issue

Interesting Fact

If i remove the end point from the webconfig , and try connecting to the web api, it is working properly . I checked the folder to see if any other webconfig is there in root folder and cannot find it

From where this web config is getting called

I restarted IIS. Deleted temporary files in Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files. But not working


Solution

  • It seems like the default website directory was pointing to a different project location Go to IIS manager enter image description here

    • Select Default Web site enter image description here
    • go to basic setting in right hand side enter image description here
      • Check if the Physical path is pointing to a different location

    enter image description here

    • If the path is not pointing to above, change the physical path to

    %SystemDrive%\inetpub\wwwroot

    enter image description here