Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net core Service Unavailable after Publish to IIS

After I published my up to IIS when I try to access it I get the error: Service Unavailable

HTTP Error 503. The service is unavailable.

What should I do next?

I use Windows Server 2008(64 - bit) with IIS 8.5. The app is web api .NET CORE 2.2.1.

On the Windows machine I have installed:

  • Microsoft .NET CORE 2.2.1 - Windows Server Hosting
  • Microsoft .NET CORE Runtime - 2.2.1(x64)
  • Microsoft .NET CORE Runtime - 2.2.1(x86)
  • Microsoft Visual C++ 2015 Redistributable(x86) - 14.024212
  • Microsoft Visual C++ 2015 Redistributable(x64) - 14.024123
  • Microsoft Visual C++ 2008 Redistributable - x86 - 9.0.30729.4148
  • Microsoft Visual C++ 2008 Redistributable - x64 - 9.0.30729.6161

I made a publication from the visual studio. Into IIS on modules i have AspNetCoreModuleV2.

The webconfig file I have:

<?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=".\App.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
   </system.webServer>
 </location>
</configuration>
<!--ProjectGuid: 9d04b7be-318b-4e95-aae3-c47aab07db30-->

Code from CreateWebHostBuilder Method:

 return WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>().UseSerilog((ctx, cfg) =>
            {
                cfg.ReadFrom.Configuration(ctx.Configuration)
                    .MinimumLevel.Verbose()
                    .MinimumLevel.Override("Microsoft", LogEventLevel.Information);
            });
like image 881
MrBlue Avatar asked Feb 13 '19 08:02

MrBlue


1 Answers

you can check below steps to dedect issue.

  1. ensure .net core runtime and AspNetCoreModule are installed And operating system restarted after installations.
  2. ensure your application pool .Net framework version is "No Managed Code" on iis.
  3. ensure that your application warming up properly. (open command prompt in directory where your application. type dotnet yourapp.dll and then press enter.)
  4. If you have your application running under an IIS and you set a binding with https, you need to specify a url with the SSL certificate associated to it, when you run dotnet yourapp.dll by default it will run on localhost if you don't specify on your Program.cs a call to UseUrls. Then you can call your dotnet yourapp.dll and it will work

    var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() .UseUrls("http://mywebsite.com") .Build();

  5. if app starting properly with dotnet command check access level of log file location(".\logs\stdout"). To give the applicationpool user the ability to read and write, perform the following steps https://stackoverflow.com/a/7334485/4172872

UPDATE:

Is the extension of the application really ".exe"?

<aspNetCore processPath=".\App.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
like image 166
levent Avatar answered Sep 28 '22 15:09

levent