.Net core Service Unavailable after Publish to IIS
Asked Answered
S

3

10

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);
            });
Susannesusceptibility answered 13/2, 2019 at 8:11 Comment(3)
Check EventViewer->Windows Logs->Application on the server for any errors.Szabo
No errors in eventViewer.Susannesusceptibility
learn.microsoft.com/en-us/aspnet/core/host-and-deploy/… There are more to check (once you re-enable the application pool).Linnea
F
28

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://mcmap.net/q/54843/-iis7-permissions-overview-applicationpoolidentity

UPDATE:

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

<aspNetCore processPath=".\App.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
Finicking answered 13/2, 2019 at 9:1 Comment(5)
As suggested above, the third step will give you clear picture if first 2 steps doesn't solve your problem.Ronna
1. I have both AspNetCoreModule and AspNetCoreModulev2. 2. The applicatiuon pool set to No Managed Code on IIS 3. The application work ok when i run dotnet app.dllSusannesusceptibility
can you check log file is created under .\logs\stdoutFinicking
omg wasted 3h because I did not restart. Thx microsoftVillasenor
Just commenting to say: Restart as mentioned in step 1!Charmeuse
Z
1

Also this https://github.com/dotnet/aspnetcore/issues/10117 - it's an ongoing open issue with .NET Core

This was not an issue with the "old" ASP.NET because it was able to "overlap" requests into two process :(

Zawde answered 10/9, 2021 at 9:45 Comment(1)
follow-up issue github.com/dotnet/aspnetcore/issues/41340, also affects ASP.NET Core 7Flimflam
P
0

I made msdeploy with key -enableRule:AppOffline to resolving "File_in_use" issue. After successful deploy in site directory stucked file App_Offline.htm, thats why I was receiving 503 error. I removed file, its work fine. Now I need to figure out why its happened.

Potion answered 12/2, 2024 at 14:34 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Wuhan

© 2022 - 2025 — McMap. All rights reserved.