Home > Software engineering >  Why is IIS returning a method not allowed error (405) for a wcf service?
Why is IIS returning a method not allowed error (405) for a wcf service?

Time:11-28

I've created an IIS v.10 development environment for my .net WCF service on Windows 10. The service seems to work, except for .svc files return a 405 method not allowed when I call them via a POST verb. The best advice I've heard so far is that I installed VS before I installed IIS and that I should uninstall everything and start over, this time installing IIS first.

<EventData>
    <Data>System.ServiceModel.ServiceHostingEnvironment HostingManager/30405926</Data>
    <Data>System.ServiceModel.ServiceActivationException: The service '/blah.svc' cannot be activated due to an exception during compilation.  The exception message is: Service 'com.blah.webservice.zzz.blah' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.. ---&gt; System.InvalidOperationException: Service 'com.blah.webservice.zzz.blah' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
   at System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreApplicationEndpoints(ServiceDescription description)
   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.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity)</Data>
    <Data>w3wp</Data>
    <Data>13140</Data>
  </EventData>

Note the exact same code works in three other Windows 10 development environments and so this indicates to me that there's nothing wrong with the code or web.config.

The handler mapping in IIS appears to be fine, the error says its a compilation error, and so what else could be causing it not to compile on this Win 10 box and not the others?

CodePudding user response:

I deleted the site in IIS and recreated it almost exactly as I had before but, instead of binding only https and port 443, I also bound http and port 80. That seemed pointless as the site only runs https, but I figured there might be a lazy developer at Microsoft who said, "close enough for government work" and required http and port 80. Suddenly it started working. To confirm if that was what fixed it, I turned off the http binding and sure enough the 500 error came back.

  • Related