Why web API return 404 when deploy to IIS

6.5k views Asked by At

Windows Server 2012 R2, IIS, VS2013 I have implement a ASP.NET web api, when I debug in VS2013, it can open IE, and I can call my web api correctly. http://localhost:42508/api/log/111

I have use "publish" in VS2013, and deploy all files to D:\api_publish.

Now, I set up IIS, and under "Default Web Site", I add a application "serverapi". Now I set "physical path" to D:\api_publish\bin (where serverapi.dll is at). then I use below URL to access API, http://192.168.1.100/serverapi/api/log/111

But it return 404 - File or directory not found.

UPDATE:

After I set "Default Web Site" to another folder path, and set Application "physical path" to D:\api_publish\, Now when I access http://192.168.1.100/serverapi/api/log/111, it will return HTTP 500 error.

2

There are 2 answers

0
DavidG On BEST ANSWER

There are a couple of issues that I can see here.

  1. The physical path should be set to D:\api_publish and not in the bin folder.
  2. Check the application pool is set to use .NET CLR Version v4.

As you mentioned in the comments, the default website already points to the same physical folder. You can either:

  1. Move the default website to another path.
  2. Use the default website instead of the serverapi one you created.
0
Pavel Timoshenko On

You should use D:\api_publish as physical path. Bin folder can not be used for that.