'The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http baseadd

I have a ADFS enabled asp.net mvc2 application and is configured with HTTPS binding (Port No:443) in the IIS. The site is configured as DefaultWebSite in the IIS .I have a WCF service: ChartsService.svc within the asp.net mvc2 project which is used for a silverlight project present in the same solution. After complete testing in the local development environment, I have deployed the code to higher environments. It worked without any issues in all the environments. All of sudden in Staging server when I tried to smoke the silverlight project, I am getting a WCF error as mentioned below:

System.InvalidOperationException The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address. Either supply an http base address or set HttpGetUrl to an absolute address.

System.ServiceModel.ServiceActivationException: The service '/ChartsService.svc' cannot be activated due to an exception during compilation.  The exception message is: The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address.  Either supply an http base address or set HttpGetUrl to an absolute address.. ---> System.InvalidOperationException: The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address.  Either supply an http base address or set HttpGetUrl to an absolute address.
   at System.ServiceModel.Description.ServiceMetadataBehavior.CreateHttpGetEndpoints(ServiceDescription description, ServiceHostBase host, ServiceMetadataExtension mex)
   at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
   at System.ServiceModel.ServiceHostBase.InitializeRuntime()
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   --- End of inner exception stack trace ---
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)

The Staging webserver is using IIS7.0. Currently I have following configuration in the web.config:

<behaviors>
        <serviceBehaviors>
            <behavior name="VATScan.Web.ChartsServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="DemoApp.Web.ChartsServiceBehavior" name="DemoApp.Web.ChartsService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding" contract="DemoApp.Web.IChartsService" />
        </service>
    </services>

what surprises me that it is still working fine in all higher environment except in Staging with the same configuration as mentioned above.

Can anyone help me to resolve this issue?



Solution 1:[1]

The answer above is one solution and here is another.

Try this:

<serviceBehaviors>
    <behavior name="VATScan.Web.ChartsServiceBehavior">
        <serviceMetadata httpGetEnabled="true" httpGetUrl="[your service address]" />
        <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
</serviceBehaviors>

Replace [your service address] with something like "http://localhost:8080/ChartsServiceBehavior"

Did it do the trick?

Check this: https://social.msdn.microsoft.com/Forums/vstudio/en-US/2fd858cb-8988-444f-868c-2ceea9cc9705/httpgetenabled-property?forum=wcf

Solution 2:[2]

I have modified httpGetEnabled to httpsGetEnabled in the below code in web.config and it resolved the issue.

<behaviors>
        <serviceBehaviors>
            <behavior name="DemoApp.Web.ChartsServiceBehavior">
                <serviceMetadata httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="DemoApp.Web.ChartsServiceBehavior" name="DemoApp.Web.ChartsService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding" contract="DemoApp.Web.IChartsService" />
        </service>
    </services>

Solution 3:[3]

I ran into this problem today but none of the above solutions worked for me. I got it solved by doing the below.

Check what type of "ServiceHost" you are trying to open. For ex:

..
myServiceHost = new ServiceHost(typeof(CMDataCollector.CMDataService));
myServiceHost.Open();      //this line was giving the above exception
..

The type of "ServiceHost" should be the service name in your config as shown below.

      <service name="CMDataCollector.CMDataService">
        <endpoint address="rest" binding="webHttpBinding" contract="CMDataCollector.IRealtimeDataService" behaviorConfiguration="jsonBehavior" />
        <endpoint address="" binding="basicHttpBinding" contract="CMDataCollector.IRealtimeDataService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:9080/TRealtimeData/" />
          </baseAddresses>
        </host>
      </service>

The type of "ServiceHost" and the service name in the config should be same. Then you can open the "ServiceHost" and start the service

Solution 4:[4]

Either supply an HTTP base address or set HttpsGetUrl to an absolute address.

This error happened because the setting is logically wrong. If you enable the httpGetEnabled means, you allow clients to retrieve metadata via HTTP(means clients can get information about those methods services provided). And if you don't provide a URL for HTTP, how can clients retrieve metadata from HTTP. So the error message alert you to provide a URL.

You have three options.

  1. Provide httpGetUrl as the other answer showed above
  2. Binding an address via IIS

Bindings enter image description here

  1. Set httpGetEnabled to false or some answer modify httpGetEnabled to httpsGetEnabled means they only have HTTPS bindings setting on their IIS

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 santosh kumar patro
Solution 3
Solution 4