My Technical Notes

Tuesday, 30 September 2014

Ignoring WCF *.svc files in ASP.NET routing

While writing a WCF .svc service in ASP.NET, I kept getting the 404 error: `The resource cannot be found.`

I spent ages Google-ing for the answer, which turned out to be quite simple: ignore requests containing `.svc` and the problem will go away. Add the following line to `RouteConfig.RegisterRoutes` method:

routes.IgnoreRoute("{*svc}", new { svc = @".*\.svc(/.*)?" });

Note that the inspiration comes from Phil Haacks website.

No comments: