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.
Deploying web api .net 5 to hosting failing.
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.
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>();
});
}
2 answers
Sort by: Most helpful
-
P a u l 10,746 Reputation points
2021-09-18T21:21:48.12+00:00 -
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