0

I'm converting an old .NET WCF service to Web API 2

To maintain backwards compatibility I have applied a RoutePrefixAttribute to my controller as shown:

RoutePrefix

All has gone pretty smoothly until I try to publish my service and access it via IIS

When I run my service via localhost (debugged from Visual Studio) and make a request via Postman all is well and I get the expected response:

localhost

However, after I publish the site to IIS, set a host entry and try to access the same endpoint:

SSRSV3

I receive a 404 not found:

404

I did some playing around, and decided to remove the ".svc" from my RoutePrefixAttribute for my Controller. And voila, I can now hit my endpoint via IIS:

good

So my question is: Does Web API 2 not support the ".svc" or even perhaps periods in their routes? Has anyone encountered something similar and found a reasonable workaround?

Thanks

1 Answers1

1

My issue was as Kiran Challa indicated. I had to add the following line to my system.webServer handlers:

<system.webServer>
    <handlers>
        <add name="ApiURIs-ISAPI-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
</system.webServer>

More information here: Dots in URL causes 404 with ASP.NET mvc and IIS

Community
  • 1
  • 1