question

davidbuckley-4911 avatar image
0 Votes"
davidbuckley-4911 asked Bruce-SqlWork answered

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.

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>();
                 });
     }
dotnet-csharpwindows-server-iis-generaldotnet-runtime
sc1.png (26.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @davidbuckley-4911 ,

The logs you showed is the message show in console when the application run in VS. The console will display this message regardless of whether the application is successfully launched. You use logging.AddConsole(); to make message record in logs. So it cannot provide any useful information about the issue. Please show more other information. For example event viewer, error page, error status code and sub status code.

0 Votes 0 ·
Paul-5034 avatar image
0 Votes"
Paul-5034 answered Paul-5034 commented

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.

· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please see above. I Added my program.cs I am already using run. What i need is more loggin info to diagnose what is going wrong @Paul-5034

0 Votes 0 ·
Paul-5034 avatar image Paul-5034 davidbuckley-4911 ·

Are you able to navigate to the project folder on your web host to run dotnet run in a command window? It might output any exceptions that may be occurring.

0 Votes 0 ·

No this is on a third party hosting company I dont control the server @Paul-5034

0 Votes 0 ·

IIt all runs fine locally

0 Votes 0 ·
Paul-5034 avatar image Paul-5034 davidbuckley-4911 ·

If you're able to access the command line on your host it would be worth running dotnet --info too to ensure that the runtime version your app is targeting is installed.

0 Votes 0 ·

As I already stated I cant access the host its not remote desktop am afraid.

0 Votes 0 ·
Show more comments
Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.