Minimal API service deployed to IIS does not work

Dmitriy Reznik 241 Reputation points
2023-08-29T21:14:37.6333333+00:00

I have a minimal api service deployed to IIS using Azure DevOps pipeline. As the service does not work as expected (500 - Internal server error), I checked the IIS. I see that app settings cannot be read. IIS can see only the automatically generated web.config:
User's image

But our actual app settings are in the appsettings.json file. How can I fix this?

The same issue happens if I deploy manually, without Azure pipeline.
I cannot open failed request tracing, as well as other items on IIS for that particular website:

User's image

Windows development | Internet Information Services
0 comments No comments
{count} votes

Answer accepted by question author
  1. Lex Li 6,037 Reputation points
    2023-08-30T01:01:21.7633333+00:00

    web.config is commonly used to configure IIS, so even if you are not using ASP.NET 4.x you need it when deploying ASP.NET Core bits. For example, ASP.NET Core module settings are necessary.

    "I see that app settings cannot be read" is desired. IIS Manager only integrates with ASP.NET 4.x settings, no more with ASP.NET Core.

    The other errors you reported indicate you didn't install ASP.NET Core module yet. Install the hosting bundle from a download page like https://dotnet.microsoft.com/en-us/download/dotnet/6.0 and you are good to go next.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 82,146 Reputation points Volunteer Moderator
    2023-08-31T15:36:54.2433333+00:00

    with min api (.net core) app, the web.config is used to configure the asp.net core hosting module, that loads and runs an asp.net core app in IIS. did you install?

    https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/hosting-bundle?view=aspnetcore-7.0

    1 person found this answer helpful.

  2. Solace 0 Reputation points
    2023-08-30T00:48:21.2166667+00:00

    This indicates that your web.config includes something that the version of IIS doesn't understand.

    Try to comment out all the contents of the web.config file and ensure that the error clears, then slowly reintroduce parts to determine what is causing the problem.

    Is this doesn't work, ensure that the <aspNetCore>is in the web.config file. You may need to reference if you need to install it. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/aspnet-core-module?tabs=aspnetcore2x


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.