0

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?

Tom McDonald
  • 1,532
  • 2
  • 18
  • 37
  • The following may (or may not) be helpful: http://proq.blogspot.com/2012/09/wcf-on-iis-and-windows-8.html . Search: `add svc handler mapping iis 10` – Tu deschizi eu inchid Nov 09 '22 at 20:00
  • fyi, the best advice I got was here https://stackoverflow.com/questions/35724165/405-method-not-allowed-wcf-webservice but it didn't work – Tom McDonald Nov 09 '22 at 20:04
  • @user9938 thanks, I tried that , no dice – Tom McDonald Nov 09 '22 at 20:05
  • after uninstalling and reinstalling IIS it went back to the 500 error saying cannot be activated due to exception during compilation..no endpoints defined. They are defined because the same code works on three other dev machines. – Tom McDonald Nov 09 '22 at 20:10
  • Usually nothing escapes from WCF tracing, https://learn.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/tracing/configuring-tracing So, enable it and see what it captures when the issue is reproduced. – Lex Li Nov 09 '22 at 21:10
  • "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" is probably worst. The installation order matters a little, as WCF needs an extra activation step to register itself on IIS, but you don't need to reinstall everything, but follow https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/deploying-an-internet-information-services-hosted-wcf-service#ensure-that-iis-aspnet-and-wcf-are-correctly-installed-and-registered VS is irrelevant. – Lex Li Nov 09 '22 at 21:12
  • @LexLi thanks for the advice, I setup tracing, but that also doesn't seem to be working. Perhaps its related. I've run tracing before, so I just turned it on, per your suggestion, but the log file is empty despite may test attempts. – Tom McDonald Nov 09 '22 at 21:44
  • See if the following is helpful: https://stackoverflow.com/questions/11116134/wcf-on-iis8-svc-handler-mapping-doesnt-work/24487108 – Tu deschizi eu inchid Nov 09 '22 at 21:58
  • If WCF tracing log is empty, then likely the WCF request was blocked before being processed by WCF itself. You can instead enable FRT to learn more on the 405 errors, https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis Different scenarios require different tools, so even if WCF tracing gives empty results it gives you some hint. – Lex Li Nov 10 '22 at 01:56
  • Maybe it's because the server itself has some less environment installed, so IIS can't accept POST requests. – sssr Nov 10 '22 at 02:09
  • @LexLi I'll enable FRT,FYI, I've edited the question to include my exact error message. Note, I'm getting a 500 error, after reinstalling IIS. The 405 error was pre-reinstallation. – Tom McDonald Nov 10 '22 at 16:34
  • I got tracing working, I had to change the switchvalue to something valid. The trace however, tells me exactly what's in the windows event logs and so is just repetitive. – Tom McDonald Nov 10 '22 at 18:45

1 Answers1

0

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.

Tom McDonald
  • 1,532
  • 2
  • 18
  • 37