Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET WEB API 2 Works Locally But Not On Production Web Server

I've developed a new WEB API 2 that works great locally, however when I upload the same code to my production server (Arvixe in this case) all I get is a 404 when I call it. I've spent HOURS searching the web, reading forums, etc.. and have been able to find no resolution, so I'm asking here as my last effort.

I'm currently only testing with the default project that gets created when you do New Project > ASP.NET Web API 2 Empty Project in Visual Studio. This creates an empty project with a single ValuesController. You should be able the JSON response by called /api/values, but this doesn't even work.

I'm using Fiddler to test the API locally and on the web server.

http://localhost:1993/api/values    <--- works great

but

http://api.mydomain.com/api/values   <--- returns 404

Note: I created a subdomain "api" in this case, but everything for the code for the API is unchanged from when it was created.

Why in the world does this work locally but not on the production web server?

like image 956
Cory Avatar asked May 02 '14 23:05

Cory


1 Answers

That the server returns 404 (Not Found) may indicate a lot of things. However you can check using the following step:

  1. Add a simple text document like readme.txt to your a folder sub-domain http://api.mydomain.com, and try to get access to that. If you can't access to that file, it means that the subdomain is not configured properly.

  2. Publish the webservice using the "Publish" functionality, so that all DLLs will be copied.

After that,try to reach the Web ApI again.

Hope that help.

like image 175
Toan Nguyen Avatar answered Sep 24 '22 14:09

Toan Nguyen