Tuesday, June 17, 2014

Step by step how to fix the “Resource not found" - CODE 404 error while accessing a WCF Data Service

       By Carmel Shvartzman

In this tutorial we'll learn how to fix the “Resource not found" - CODE 404 error  while accessing a WCF OData WCF Data Service in an Asp.Net MVC application
Essentially, while running your ODATA WCF service over the Visual Studio Development Server (Cassini) you have no problem. However, when deploying the application to an IIS server, you finish with an 404 Resource Not Found error:


That's because MVC performs a route mapping and tries to map the ODATA REST request to one of the controllers at the application. It couldn't find a controller, so returns a 404 NOT FOUND error code.
Therefore , let's say MVC not to map any request destinated to our WCF OData REST service, adding the following code to the RouteConfig.cs file :

routes.IgnoreRoute("ServiceFolder/ServiceName.svc/{*pathInfo}");



 Then rebuild the application (it needs to be compiled again, because the .cs file is compiled in the DLL) and run some OData request :





And that's all!!


Happy programming.....


כתב: כרמל שוורצמן

No comments:

Post a Comment