Search code examples
wcf

WCF Service to get data from SQL database not hosting properly


I have the WCF Service to getdata from the SQL Database for my android application. the service works fine for the WCFTestClient but its not Hosting in IIS,

HTTP Error 500.24 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

when trying to browse from IIS.

adding website in IIS

after adding new website in IIS and trying to browse

my service config file

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings />
  <!--
    For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID" />
  </system.web>
  <system.serviceModel>

      <bindings>
          <webHttpBinding>
              <binding name="restLargeBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
                  <readerQuotas maxStringContentLength="2147483647"/>
              </binding>
          </webHttpBinding>
      </bindings>
      <behaviors>

          <!--<serviceBehaviors>
              <behavior>
                  --><!--To avoid disclosing metadata information, set the values below to false before deployment--><!--
                  <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                  --><!--To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information--><!--
                  <serviceDebug includeExceptionDetailInFaults="false" />
              </behavior>
          </serviceBehaviors>-->



                  <endpointBehaviors>
                      <behavior name ="myWebEndPointBehaviour">
                          <webHttp automaticFormatSelectionEnabled="true" defaultBodyStyle="Bare" defaultOutgoingResponseFormat="Json" helpEnabled="true"/>
                          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                      </behavior>
                  </endpointBehaviors>




        <serviceBehaviors>
            <behavior name="mybehaviour">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior> 
          </serviceBehaviors>
      </behaviors>


    <!--</behaviors>-->

      <services>
            <service name="FeedbackSrvc.Service1" behaviorConfiguration="mybehaviour">
                <endpoint address="" contract="FeedbackSrvc.IService1" binding ="webHttpBinding" bindingConfiguration="restLargeBinding" behaviorConfiguration="myWebEndPointBehaviour"/>
                <endpoint address="mex" contract="FeedbackSrvc.IService1" binding="mexHttpBinding" />
            </service>
      </services>

    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
</configuration>

Solution

  • There is no error in your webconfig file, I have tested it.This is due to an IIS configuration error.I suggest you try to change the application pool setting, turn the managed pipeline mode into Classic, or you could use the ASP.NET v4.0 Classic. enter image description here

    In general, this is own to the fact that this IIS version is too old. For example hosting WCF requires configuration on IIS 7.5, we should

    1. In Developer command prompt for vs2017 Install the asp.net. aspnet_regiis.exe -i enter image description here

    2. Enable the WCF HTTP Activation.which is in turn on/off windows feature. enter image description here

    Feel free to contact me if you have any questions