Home > Back-end >  IIS .NET Core 5.0 MVC API - Getting HTTP Error 500.30 - ASP.NET Core app failed to start
IIS .NET Core 5.0 MVC API - Getting HTTP Error 500.30 - ASP.NET Core app failed to start

Time:10-28

Have tried recommendations as found in HTTP Error 500.30 - ASP.NET Core 5 app failed to start and other similar posts but not having a lot of luck.

My API works perfectly fine running with IIS Express in VS2019, but after publishing it just won't start.

This is my web.config

<?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=".\MyApi.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

Have tried both inprocess and outprocess, provided environment variables no difference.

Code is deployed to C:\inetpub\wwwroot\MyApi

IIS_IUSRS has been given read/write access to wwwroot folder

This is my working lunchsettings.json file from the VS project

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "https://localhost:44307",
      "sslPort": 44307
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MyApi": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

This is my program.cs

public class Program
{
    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                _ = webBuilder.UseStartup<Startup>();
            })
            .ConfigureServices(services =>
            {
                _ = services.AddHostedService<MyApiWorker>().Configure<EventLogSettings>(config =>
                {
                    config.LogName = "My API";
                    config.SourceName = "My API";
                });
            });

    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }
}

IIS logs in /inetpub/logs/logfiles are not all that useful (4443 was the port I used when adding to IIS).

#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2021-10-27 09:31:01
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2021-10-27 09:31:01 ::1 GET / - 4443 - ::1 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 - 500 0 2147500037 4
2021-10-27 09:31:07 ::1 GET / - 4443 - ::1 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 - 500 0 2147500037 0
2021-10-27 09:32:39 ::1 GET /swagger - 4443 - ::1 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 - 500 0 2147500037 0
2021-10-27 09:36:45 ::1 GET / - 4443 - ::1 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 - 500 0 2147500037 0

Any ideas would be greatly appreciated. I can't seem to find any meaningful logs, and the logs the app outputs never publish anything.

EDIT: Application Pool is No Managed Code Have installed dotnet-hosting-5.0.11-win.exe and rebooted and restarted IIS multiple times.

Event Log shows: Application '/LM/W3SVC/1/ROOT' with physical root 'C:\inetpub\wwwroot\myapi' failed to load coreclr. Exception message: Managed server didn't initialize after 120000 ms.

EDIT 2 Now getting this in the Event Logs:

The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID 
{3480A401-BDE9-4407-BC02-798A866AC051}
 and APPID 
{30AD8C8E-AE85-42FA-B9E8-7E99E3DFBFC5}
 to the user IIS APPPOOL\DotNetCore SID (S-1-5-82-2530134163-791093599-2246298441-3166710890-3969430272) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool.

CodePudding user response:

I was able to host on my windows IIS.

Pre-requisite: You need to have .Net Core Hosting Bundle installed on the server.

In IIS Manager,

  1. Created New Website in IIS and point to the folder where you published the code. IIS Website

  2. When the website gets created, the application pool automatically gets created which runs on ApplicationPoolIdentity. Make sure the .Net CLR version is to "No Managed Code"app pool

  3. Reset IIS

Browse the application url: http://:port/<controllername/route>

CodePudding user response:

  1. Please make sure that you have installed your .net core on server
  2. Setup your application pool to No Managed Code
  3. If still not working, please check error logs

I follow these steps https://dotnetblog.asphostportal.com/how-to-publish-asp-net-core-blazor-application-to-iis/ and my application work flawlessly.

  • Related