500 Server error when hosting WCF

17,326

Solution 1

I fixed the error by adding this to my web.config.

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

I think this happened because I had 2 bindings which both used http. Maybe someone else can elaborate.

Solution 2

Error 500 identifies any kind of server errors... try accessing the service from localhost (default settings for IIS shows errors only locally).

Try also to edit IIS settings to "Send errors to browser" or In Internet Information Services (IIS) Manager > Your Web > Error Pages > properties and select Detail errors

In this way, you can see the real error raised by your service.

Check also that, in your application pool, the correct framework version is selected

Share:
17,326
TheGateKeeper
Author by

TheGateKeeper

Updated on November 21, 2022

Comments

  • TheGateKeeper
    TheGateKeeper over 1 year

    Maybe you can help me because I am really at a loss here.

    I am trying to host my WCF service on IIS on a subdomain.

    To start, here is my file structure:

    http://s18.postimage.org/eqmjxb00n/Serv.jpg

    Inside the bin are my .dll representing my interface and it's implementation.

    Here is the web.config file:

    <?xml version="1.0"?>
    <configuration>
    
      <system.web>
        <compilation debug="false" targetFramework="4.0" />
      </system.web>    
        <system.serviceModel>
            <services>
                <service name="AuthenticatorService.Authenticator">
                    <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
                        name="AuthEndpoint" contract="AuthInterface.IAuthenticator" />
                    <endpoint address="" binding="mexHttpBinding" name="MetadataEndpoint"
                        contract="IMetadataExchange" />
                </service>
            </services>
            <behaviors>
                <serviceBehaviors>
                    <behavior>
                        <serviceMetadata httpGetEnabled="True"/>
                        <serviceDebug includeExceptionDetailInFaults="False" />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
        </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
    
    </configuration>
    

    It works locally but when I upload to IIS it just gives 500 server errors.

    Thanks!

    If it's any use here is the message from the detailed error page:

    Module  ServiceModel-4.0
    Notification    AuthenticateRequest
    Handler svc-Integrated-4.0
    Error Code  0x00000000
    Requested URL   http://service.swiftposter.com:80/auth.svc
    Logon Method    Anonymous
    Logon User  Anonymous
    

    Edit: I enabled ELMAH logging and finally got a meaningfull message:

    System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'. Parameter name: item
    

    Im going to start researching this error, but I posted here just in case someone knows what is wrong.

    Stack Trace:

    System.ServiceModel.ServiceActivationException: The service '/auth.svc' cannot be activated due to an exception during compilation.  The exception message is: This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
    Parameter name: item. ---> System.ArgumentException: This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
    Parameter name: item
       at System.ServiceModel.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item)
       at System.Collections.Generic.SynchronizedCollection`1.Add(T item)
       at System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses)
       at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
       at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses)
       at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
       at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
       at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
       at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
       --- End of inner exception stack trace ---
       at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
       at System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar)
       at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)
    
    • Darin Dimitrov
      Darin Dimitrov about 12 years
      Nothing happens when you deploy in IIS? You mentioned some 500 server error in your question title. Can you tell us a little more about it?
    • TheGateKeeper
      TheGateKeeper about 12 years
      Sorry, by nothing happens I meant it doesn't run. It just keeps giving me 500 server errors.
    • Luuk Krijnen
      Luuk Krijnen about 12 years
      is the .net version of the app-pool defined right, are Files/Databases issued with the right credentials if applicable. serveral issues can be the the problem. Do you have any more info?
    • TheGateKeeper
      TheGateKeeper about 12 years
      It is set to 4.0 and all files are accessible
    • Grits
      Grits over 5 years
      This old thread has proved useful to me big time. My site has a legacy asp.net app along with some WCF services - these WCF services have been running well for several years, but stopped working all of a sudden, mid-day yesterday. After a few hours of trying stuff in vain, came across TheGateKeeper's answer above, applied it, and that fixed my issue. In case this helps anyone - I am not 100% certain on the root cause of this, but this is my best guess as of this writing: - my WCF services possibly required the multipleSiteBindingsEnabled be set
  • TheGateKeeper
    TheGateKeeper about 12 years
    I already tried enabling errors. It gives me no info whatsoever just general errors.
  • TheGateKeeper
    TheGateKeeper about 12 years
    Hi, I tried by setting both of the address properties but it still doesn't work. Same error.
  • Min Min
    Min Min about 12 years
    Not sure, but can you check this blog? Similar error as yours. [net.micheltol.nl/post/…