Deploying web api .net 5 to hosting failing.

NOVATROOP77 266 Reputation points
2021-09-18T20:16:57.857+00:00

I am trying to deploy my .net 5 web api project which works fine locally in issexpress.

But when deploying to my web host whom say they support .net 5 I get the following logs with not much to go on.

133361-sc1.png

The Error I am getting from the above logs. As you see its not very detailed how to do i get to the root of the issues , its a swagger api with ef core it all works locally grand.

info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://127.0.0.1:38857
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\home\site\wwwroot
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...

My Web config for completeness.

<?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=".\TheHockeyLabMn.WebApi.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout.txt" hostingModel="inprocess" />  
    </system.webServer>  
  </location>  
</configuration>  
<!--ProjectGuid: c97f985a-a850-4cff-b2a0-4c3994731f1d-->  


{  
  "ConnectionStrings": {  
    "DefaultConnection": ""  
  },  
   
    "AppSettings": {  
      "Secret": ""  
    },  
    "Logging": {  
      "LogLevel": {  
        "Default": "Error",  
        "Microsoft": "Warning",  
        "Microsoft.Hosting.Lifetime": "Information"  
      }  
    },  
    "AllowedHosts": "*"  
  
  }  

I left out my connection details for security purposes.

Added program.cs at request.

  public class Program  
    {  
        public static void Main(string[] args)  
        {  
            CreateHostBuilder(args).Build().Run();  
        }  
  
        public static IHostBuilder CreateHostBuilder(string[] args) =>  
            Host.CreateDefaultBuilder(args)  
             .ConfigureLogging(logging =>  
             {  
                 logging.ClearProviders();  
                 logging.AddConsole();  
             })  
                .ConfigureWebHostDefaults(webBuilder =>  
                {  
                    webBuilder.UseStartup<Startup>();  
                });  
    }  
Internet Information Services
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,124 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,179 questions
{count} votes

2 answers

Sort by: Most helpful
  1. P a u l 10,746 Reputation points
    2021-09-18T21:21:48.12+00:00

    In your Program.cs are you calling Run or Start on IHost? Run will block but Start starts the host asynchronously. It sounds like you need to use Run to stop the process from immediately terminating.


  2. Bruce (SqlWork.com) 68,306 Reputation points
    2021-09-20T17:00:41.707+00:00

    as no errors are logged, are you sure you don't have an app_offline.htm file in the root

    0 comments No comments

Your answer

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