Reputation: 321
I recently upgraded Visual Studio to 2013 which now only uses IIS Express by default (instead of Cassini) and found I could no longer hit my WCF service javascript endpoints: Myservice.svc/js or /jsdebug, but hitting the .svc directly would work fine.
I've found that if I remove the <handlers> section of my web.config (which includes some ExtensionlessUrlHandler items), the functionality to the script endpoints is restored. I'm curious what repercussions removing the following items would have, and if there is an alternative solution.
Here is the block I removed from my Web.config:
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
Some context, I'm using .NET 4.5, MVC 5.1, WebAPI v2.1 and WCF all in one project. Essentially the newest versions of all the components.
Update 1: I'm also noticing that any WebAPI PUT's are coming back as a 404 with these handlers removed; so something is obviously missing. The other minor epiphany, is that when deployed to a live server (IIS 7.5 [Version 7.5.7600.16385]) everything works great. So there has to be a difference in the routing or handler mappings of the Visual Studio 2013 integrated version of IIS Express and a full IIS 7.5 setup.
ALSO, If I create a brand new ASP.NET web app and add a WCF service, everything works fine locally. If I then add in a WebAPI controller, the handlers section below is added to the web.config and breaks all the WCF calls. This makes it sound more like a 'bug' in Microsoft's default configuration when MVC, WCF, and WebAPI are all a part of one application.
Update 2: Here's a basic test case anyone can follow to reproduce the error I'm having.
Process to recreate base issue: (WebAPI working, WCF *.svc/js results in 404)
Partial Fix: (WebAPI PUT broken, WCF can render JS request)
Upvotes: 3
Views: 2922
Reputation: 5261
This is actually a mvc routing issue. Please modify your ~/App_Start/RouteConfig.cs as below. You need to keep the ExtensionlessUrlHandler in order for mvc routing to function normally on extensionless urls.
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//This line is the addition.
routes.IgnoreRoute("{resource}.svc/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
Upvotes: 3