6

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.

Mike Hofer
  • 16,477
  • 11
  • 74
  • 110
  • Where are you publishing the site to? A local server or Azure? – aaronR Oct 20 '17 at 03:17
  • @aaronR An IIS web server in our internal Intranet (not Azure). – Mike Hofer Oct 20 '17 at 12:56
  • Can you access a simple “hello world” html page to verify the site is running correctly? – aaronR Oct 20 '17 at 13:42
  • @aaronR Yes. The page comes up as expected. – Mike Hofer Oct 20 '17 at 13:49
  • Ok that’s good! What about if you comment out your logic in the Controller and just return a 200 ok response? This will test the ASP framework. – aaronR Oct 20 '17 at 13:50
  • @aaronR A warning appeared in the Windows Event Log! See the update. – Mike Hofer Oct 20 '17 at 14:19
  • Ok progress! We will get there! – aaronR Oct 20 '17 at 14:21
  • Could it be this issue? https://stackoverflow.com/questions/32780315/could-not-find-a-part-of-the-path-bin-roslyn-csc-exe – Greg Oct 20 '17 at 14:33
  • Do you need to set up an app pool? Make sure the IIS process has the right permissions to run the CSC.exe. – aaronR Oct 20 '17 at 15:09
  • @aaronR The application is running in its own application pool, under a service account that has all appropriate permissions. It's the same service account we use for other .NET Web applications (including another Web API application). – Mike Hofer Oct 20 '17 at 16:35
  • @Greg I added the missing target to the .csproj file, and that resolved the issue with the missing Roslyn compiler assemblies. However, I'm still getting a 503 for the controller methods. – Mike Hofer Oct 20 '17 at 16:37
  • Check if precompiling your app before deployment works for you. – tx fun Oct 23 '17 at 17:44
  • @txfun Precompiling the app *during* publish fails. I have to manually build, then publish. I'm able to get the Roslyn files into the bin folder, but they do not get copied over to the server during publish. – Mike Hofer Oct 23 '17 at 18:00
  • kindly check if your web.config being published into the /publish folder? right click->properties->check build action (shld be content) – tx fun Oct 23 '17 at 18:09
  • @txfun Yes, it is. It's also the correctly transformed version. – Mike Hofer Oct 23 '17 at 18:59
  • Have you considered antivirus blocking things? – Dai Bok Oct 26 '17 at 13:32

1 Answers1

1

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