To call ASP.NET MVC 4 Web API, I am using following convention to call its service
$.getJSON("api/products/", ...
If my url of the site is a root such as http://localhost:10234, everything is fine.
But once the url became http://localhost/SomeApp, the ajax call failed because
.getJSON actually calls http://localhost/api/products instead of http://localhost/SomeApp/api/products. What should I do in this case to correct the location. “/api/products/” or “~/api/products” does not work.
in the first part of my _Layout.cshtml, I put
and changed my call in javascripts to
And this fixed the problem.