Showing posts with label wcf. Show all posts
Showing posts with label wcf. Show all posts

Friday, January 29, 2016

HTTP Error 404.17 when running WCF service in Visual Studio 2015 (VS2015)

PROBLEM: On Windows 7 with Visual Studio 2012 I could run an asp.net .NET 3.5 project with WCF services.  After installing Windows 10 and Visual Studio 2015, I could no longer debug a WCF service which previously ran fine on Windows 7 and Visual Studio 2012.  I get the following error: "

HTTP Error 404.17 - Not Found - The requested content appears to be script and will not be served by the static file handler. - Most likely causes: The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler. Things you can try: If you want to serve this content as a static file, add an explicit MIME map."

SOLUTION: I had to turn on a number of Windows features that aren't on by default:

  • .NET Framework 3.5 (includes .NET 2.0 and 3.0) > Windows Communication Foundation HTTP Activation
  • .NET Framework 3.5 (includes .NET 2.0 and 3.0) > Windows Communication Foundation Non-HTTP Activation
  • .NET Framework 4.6 Advanced Services > WCF Services > HTTP Activation (probably not required for my project but useful for the future)


I also ran this but I don't think I needed to / should have (http://ngeor.net/2011/07/iis-7-gives-404-17-error-with-svc-wcf-services/):

"%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" –r

And then despite all this things didn't work, I had to manually update the IIS Express settings used by Visual Studio... WHICH are hidden away in a hidden folder in your solution e.g.

[PROJECT FOLDER]\.vs\config\applicationhost.config

I had to add the following to the section starting with <handlers accessPolicy="Read, Script">

<add name="xoml-64-ISAPI-2.0" path="*.xoml" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
<add name="rules-64-ISAPI-2.0" path="*.rules" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
<add name="svc-ISAPI-2.0-64" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
<add name="xoml-ISAPI-2.0" path="*.xoml" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
<add name="rules-ISAPI-2.0" path="*.rules" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
<add name="xoml-Integrated" path="*.xoml" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" />
<add name="rules-Integrated" path="*.rules" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" />
<add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" />

There are lots of other similar applicationhost.config files but this is the one you need to update.

I thought that because of our source control branching approach that I'd need to manually update this anytime I create a new branch that needs WCF working BUT apparently there is a project file (not web.config) setting: UseGlobalApplicationHostFile, which you can set to true to just use the global setting (which is stored in Documents\IISExpress\config) http://stackoverflow.com/questions/32940080/visual-studio-2015-debugger-uses-local-applicationhost-config-instead-of-global and http://stackoverflow.com/questions/12946476/where-is-the-iis-express-configuration-metabase-file-found (that being said, I created a new branch the other day and hadn't yet set that setting or updated the Visual Studio applicationhost.config file and I was still able to debug the WCF services... go figure!