500 Server error when hosting WCF

1

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)
c#
winforms
wcf
iis
asked on Stack Overflow Mar 30, 2012 by TheGateKeeper • edited Mar 30, 2012 by TheGateKeeper

3 Answers

3

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.

answered on Stack Overflow Mar 30, 2012 by TheGateKeeper
0

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

answered on Stack Overflow Mar 30, 2012 by AndreaCi
0

Your service address and service's metadata address should not be the same. It should be like:

<system.serviceModel>
 <services>
   <service name="AuthenticatorService.Authenticator">
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
                name="AuthEndpoint" contract="AuthInterface.IAuthenticator" />
       <endpoint address="mex" binding="mexHttpBinding" name="MetadataEndpoint"
                contract="IMetadataExchange" />
   </service>
  </services>
  ...
</system.serviceModel>

http://msdn.microsoft.com/en-us/library/ms733766.aspx

answered on Stack Overflow Mar 30, 2012 by Min Min

User contributions licensed under CC BY-SA 3.0