I have deployed a web api project to a on-prem server. The server returns razor pages properly; but web api calls return 404. I've verified that web api controller code isn't being hit.
So the routing mechanism doesn't seem to be wired up correctly.
I have installed .NET 4.5 and ASP.NET MVC 4 on the server. I also tried setting Copy Local for all DLLs.
So I discovered that I am able to fetch the web-api data via the browser or Fiddler (by specifying a full path). But my app doesn't work on the server.
Apparently the URLs in the json calls are acceptable on the dev machine and incorrect for the server.
The call in question looks like:
$.getJSON("/api/imagemetrics/" + partNumber, ....
I haven't figured yet out how to make it work on both machines. (I'm a bit of a newbie to JS/HTML5/XHR).
Are your ajax calls coming from a different domain than where your API is hosted? It doesn't sound like its in issue with your URI's it may be a problem with CORS.
Doers get what they want! Everyone else gets what they get.
calvindale
Member
16 Points
12 Posts
Web API calls work on dev machine; but return 404 on server
Nov 16, 2012 09:18 PM|LINK
Hello,
I have deployed a web api project to a on-prem server. The server returns razor pages properly; but web api calls return 404. I've verified that web api controller code isn't being hit.
So the routing mechanism doesn't seem to be wired up correctly.
I have installed .NET 4.5 and ASP.NET MVC 4 on the server. I also tried setting Copy Local for all DLLs.
Any ideas?
Many thanks!
remojr76
Participant
902 Points
303 Posts
Re: Web API calls work on dev machine; but return 404 on server
Nov 16, 2012 11:34 PM|LINK
what is the message in the response body?
calvindale
Member
16 Points
12 Posts
Re: Web API calls work on dev machine; but return 404 on server
Nov 16, 2012 11:41 PM|LINK
404 - File or directory not found.
calvindale
Member
16 Points
12 Posts
Re: Web API calls work on dev machine; but return 404 on server
Nov 17, 2012 12:02 AM|LINK
So I discovered that I am able to fetch the web-api data via the browser or Fiddler (by specifying a full path). But my app doesn't work on the server.
Apparently the URLs in the json calls are acceptable on the dev machine and incorrect for the server.
The call in question looks like:
$.getJSON("/api/imagemetrics/" + partNumber, ....
I haven't figured yet out how to make it work on both machines. (I'm a bit of a newbie to JS/HTML5/XHR).
remojr76
Participant
902 Points
303 Posts
Re: Web API calls work on dev machine; but return 404 on server
Nov 17, 2012 05:58 AM|LINK
Are your ajax calls coming from a different domain than where your API is hosted? It doesn't sound like its in issue with your URI's it may be a problem with CORS.
calvindale
Member
16 Points
12 Posts
Re: Web API calls work on dev machine; but return 404 on server
Nov 19, 2012 02:50 PM|LINK
Removing the preceeding forward slash from the URI did the trick.