404 when running .net 4 WCF service on IIS (no svc file)

I'm testing out a REST service in WCF on .net 4 - i.e. no svc file. It works great when running against the VS dev server but when I switch it to run against IIS I get 404s when trying to browse the help page or hit any of the service methods.

I've dropped back to a bare bones service to just get it running on IIS but I'm not sure what's wrong with it.

The global.asax simply has

    protected void Application_Start(object sender, EventArgs e)
        RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(DataPortalService)));

and the service itself is as simple as it gets:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class DataPortalService : IDataPortalService
    [WebGet(UriTemplate = "Test/TestMethod")]
    public string TestMethod()
        return "Hi!";

public interface IDataPortalService
    string TestMethod();

and config file of

        <compilation debug="true" targetFramework="4.0" />

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />


Hitting the /help page or the method gives me a 404.0.

I presume I'm just missing some setting in IIS to kick it in to life although it's a bit daft that it works fine on the dev server but not IIS.


Solved it after a dig around some other forums.

I initially added the following to my web config:

        <remove name="svc-Integrated-4.0" />
        <add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />

Clearly by default IIS doesn't know what to do with the extensionless requests and passed them on to the static file handler.

Given that MVC is using the same routine architecture I figured that the basic MVC site template must have some config in similar to the above since my MVC sites have worked fine when moved to IIS.

It turns out that they have a slightly different config and have the following entry instead:

    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>

Both configs seem to work ok but I settled on using the 2nd option in this case.

I had runAllManagedModulesForAllRequests="true" in my web.config but still couldn't get past the 404.0. Also tried installing "IIS 7 Recommended Configuration" without any luck. Rerunning aspnet_regiis solved the problem to me.

  1. In the Run dialog box, type cmd, and then click OK.

  2. At the command prompt, use the cd command to change the directory of the Aspnet_regiis.exe version you want to use. By default, Aspnet_regiis.exe is located in the following directory: systemroot\Microsoft.NET\Framework\versionNumber

  3. Then run the following command: aspnet_regiis -ir

This will register "svc-Integrated-4.0" in the Handler Mappings.

HTTP 404 code can be returned also if you don't have some components of .NET framework installed.

There's for instance Windows Communication Foundation HTTP Activation feature in .NET Framework 3.5 and in .NET Framework 4.6 there are HTTP Activation, Message Queuing (MSMQ) Activation and a few more.

In Windows 10 these features aren't installed by default, so please keep in mind to take a look at Windows Features.

On IIS 5.1 on my machine, the .svc page was served only when I added HTTP Handler at Web Site level as well as virtual folder level. This should ideally work by inheritance!

Extention : .svc

Executable :


Need Your Help

How to handle back button on Ionic 2

ionic2 back-button back-button-control

How can I handle the back button action on Ionic 2?

How to get and change URL variable PHP

php html hyperlink

Hi could anyone help me with this