When working with AJAX web service you may notice that one service operation of some service (in this case Service1.svc) works well, but at some machines following exception can be thrown:
Server Error in '/MvcApplication1' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /MvcApplication1/Service1.svc/jsdebug
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
I figured out that the problem happens in our team when developers use mixed x86 and x64 environments. For example, I have built the service at 64-bit system and all team members who use x64 platform can use service.
Unfortunately all team poor guys in team who use x86 platform can see exception shown above when the operation is invoked on service.
In fact this exception indicates the routing problem in your application. Our application is is ASP.NET MVC, which in Global.asax registers a number of routes like:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{token}",
new { controller = "Abc", action = "Create", token = UrlParameter.Optional, id = UrlParameter.Optional }
);
To experience this issue do following. At x86 machine, enter in the browser http://localhost/YourServiceApp/Service1.svc. The page will answer properly. Then try following URL: http://localhost/YourServiceApp/Service1.svc/jsdebug.
No the error shown above will appear. To be sure that the routing is problem, goto Global.asax and comment out all MapRoute statements. Now, open http://localhost/YourServiceApp/Service1.svc/jsdebug again and JS-proxy will be generated.
This means that AJAX service works properly now. Unfortunately no any other MVC-controller action will work .
Solution
To fix the problem I have created the folder Services and moved the service Service1.svc in there. Finally I appended in Global.asax following line of code:
routes.IgnoreRoute("Services/*.svc");
Now, the AJAX service works in both x86 and x64 environment.
Hope this helps.
Posted
Mar 18 2011, 07:07 PM
by
Damir Dobric