.net core application error 502.5 if run as virtual directory in IIS

3

I am having problem configuring .net core application to work as virtual directory in iis. If i start .net core application directly with its port it works fine.

I am getting 502.5 response and in event viewer there is this message

Application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE' with physical root 'C:\inetpub\wwwroot\' failed to start process with commandline ' ', ErrorCode = '0x80070057 : 0.

I have removed parent handlers in .net web.config like this

<handlers>
            <remove name="httpPlatformHandler"/>
            <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
            <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        </handlers>
c#
.net
windows
iis
deployment
asked on Stack Overflow Jun 23, 2018 by Mirhat • edited Jun 23, 2018 by Mirhat

1 Answer

2

In order to run an ASP.NET Core application make sure you:

  • Have the ASP.NET Core Web Hosting Bundle (required for a server!)
  • Publish your application - should include a web.config
  • Deploy the Publish output to your server
  • Set up an Application Pool
  • Set .NET Framework to none (optional but usually a good idea)
  • Use an account that has read permissions in the virtual folder

The hosting bundle includes the ASP.NET Core Module for IIS which allows IIS to launch. Without ASP.NET Core apps will not run on IIS.

You also need to publish your application, which produces a final output folder that contains your binaries and config files including a web.config in the root and a wwwroot root folder with your content. To test you should make sure you can run your app from the command line with:

dotnet yourMainAssembly.dll -c Release

If this doesn't work fix this first as this is essentially what IIS fires. once the standalone works you can try using IIS.

ASP.NET Core projects created in Visual Studio automatically include a web.config and that should have everything you need to run under IIS. For a basic setup that should be all you need. The generated web.config should take care of getting your app running.

If you're using a virtual you might have an issue with the parent side configuration bleeding into your virtual because virtuals inherit settings from the parent. If that's the case either choose the same version of .NET Framework for your application pool, or share the application pool with the parent. Alternately you can use <clear /> in the <handlers> section to clear out any handlers from up the hierarchy.

<configuration>
  <system.webServer>
    <handlers>
      <clear>
      <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
      <environmentVariables />
    </aspNetCore>
  </system.webServer>
</configuration>

I have a blog post with a lot more details on hosting on IIS along with some additional configuration for static files here:

answered on Stack Overflow Jun 23, 2018 by Rick Strahl • edited Jun 23, 2018 by Rick Strahl

User contributions licensed under CC BY-SA 3.0