locked
Sample WebAPI Works on IIS Express but Not on IIS Server - 503 Service Unavailable RRS feed

  • Question

  • User820031305 posted

    I've been trying to get the VS WebAPI sample WeatherForecast working on our IIS server for a while now. Running it from VS 2019 and testing with Postman works fine on my dev machine localhost. As a complicating factor, there is a reverse proxy on the server so I'm not sure how that is effecting this situation.

    The 5.0.2 hosting bundle is installed on the server.

    Application pool is "No managed code".

    Windows Server 2012 R2 version 6.2 build 9200.

    IIS version 8.5.9600.16384

    Test: trying to "Browse Website" from within IIS manager http://cohegis.houstontx.gov:5000/WeatherForecast 

    Error: The device or resource (cohegis.houstontx.gov) is not set up to accept connections on port 5000

    The bindings are set to ports 5000 and 5001. I didn't know what to set these to.

    Test: trying from Postman GET https://cohegis.houstontx.gov/WeatherForecast

    Error: 503 Service Unavailable

    Test: trying the reverse proxy from Postman GET https://cohegis.houstontx.gov/cohgisweb/WeatherForecast

    Error: 404 - File or directory not found.

    For debugging purposes, I tried to get logging to work but that didn't happen. I set write permissions on the logs folder to my application pool.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="." inheritInChildApplications="false">
        <system.webServer>
          <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
          </handlers>
    	  <aspNetCore processPath="dotnet"
    			arguments=".\WebApplication1.dll"
    			stdoutLogEnabled="true"
    			stdoutLogFile=".\logs\stdout"
    			hostingModel="inprocess">
    		<handlerSettings>
    			<handlerSetting name="debugFile" value=".\logs\aspnetcore-debug.log" />
    			<handlerSetting name="debugLevel" value="FILE,TRACE" />
    		</handlerSettings>
    	  </aspNetCore>
        </system.webServer>
      </location>
    </configuration>
    <!--ProjectGuid: C734A945-3323-4E17-811C-7F6D186E6A4C-->

    Any thoughts on what to try next?

    Thanks for the help.

    <!--?xml version="1.0" encoding="utf-8"?--> <configuration> <location path="." inheritinchildapplications="false"> <system.webserver> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourcetype="Unspecified"></add> </handlers> <aspnetcore processpath="dotnet" arguments=".\WebApplication1.dll" stdoutlogenabled="true" stdoutlogfile=".\logs\stdout" hostingmodel="inprocess"> <handlersettings> <handlersetting name="debugFile" value=".\logs\aspnetcore-debug.log"></handlersetting> <handlersetting name="debugLevel" value="FILE,TRACE"></handlersetting> </handlersettings> </aspnetcore> </system.webserver> </location> </configuration> <!--ProjectGuid: C734A945-3323-4E17-811C-7F6D186E6A4C-->

    Wednesday, February 3, 2021 5:38 PM

Answers

  • User-474980206 posted

    As you are using the iis hosting module in process mode, the ports are set by iis configuration, not asp.net core. Typically that would be port 80 and 441

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 4, 2021 2:02 AM

All replies

  • User475983607 posted

    You probably need to set a firewall rule to allow posts 5000 and 5001.  See your firewall docs.

    Wednesday, February 3, 2021 9:18 PM
  • User-474980206 posted

    As you are using the iis hosting module in process mode, the ports are set by iis configuration, not asp.net core. Typically that would be port 80 and 441

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 4, 2021 2:02 AM
  • User1120430333 posted

    You could deploy to local IIS on your development machine the same IIS that's running on a server machine as a test.

    You can also just take IISExpress out the picture and use local IIS for ASP.NET code development and debugging against local IIS.

    Enable debugging for ASP.NET apps - Visual Studio | Microsoft Docs

    Thursday, February 4, 2021 2:44 AM