Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web API site virtual directory is accessible, but controller actions return HTTP 503

We were unsuccessful in getting an OWIN Web API service deployed using a Windows Service (as described in this StackOverflow question). After numerous attempts to resolve the issue, we decided to simply create an ASP.NET Web API site and deploy it through IIS.

When run locally, all actions are reachable. However, if we publish the site (using Build -> Publish, or any variant thereof), we observe the following:

  1. When we browse to the machine name and port, we are presented with a directory listing for the virtual directory.
  2. When we request a controller action, the site returns HTTP Error 503. The service is unavailable.
  3. No errors are logged to the Windows Application Event Log on the target server.
  4. The same occurs when the request is executed on either the hosting server or a client machine.

The URL ACL has been created as follows:

netsh http add urlacl http://+:8098/api user=Everyone

The firewall doesn't appear to be blocking the port (as we can get to it through step 1, above). The URL ACL exists, and everyone in the company has access to it (as they should). We do not know why this is occurring, and can't seem to find a suitable answer.

Can someone please suggest a cause or possible solution that we might have overlooked?

UPDATE

The following (abbreviated) warning info appeared in the Windows Application Event Log after removing logic from the Controllers and republishing:

Event code: 3005  
Event message: An unhandled exception has occurred.  
Exception information: 
Exception type: HttpException 
Exception message: Could not find a part of the path 'D:\websites\LoggingWebApi\bin\roslyn\csc.exe'.    

This is interesting. It looks like Publish is not distributing the Roslyn compiler with the build.

UPDATE 2 The simplest action method on the controller is this:

[HttpGet]
[Route("Status")]
public string Status()
{
    return "Online";
}

Even after manually copying the Roslyn assemblies to the server in the bin folder, that method returns HTTP 503. No error messages appear in the Application Event Log.

When this method is run locally (on my machine) it returns a JSON string that I can open in a text editor.

like image 864
Mike Hofer Avatar asked Oct 17 '17 14:10

Mike Hofer


1 Answers

The URL ACL has been created as follows:

netsh http add urlacl http://+:8098/api user=Everyone

I had a similar issue and ended up deleting the URL ACL reservation on the web server. That fixed it. Give that a try.

netsh http delete urlacl url=http://+:8098/api

like image 154
Ingram Marray Avatar answered Oct 11 '22 11:10

Ingram Marray