.Net core Service Unavailable after Publish to IIS
you can check below steps to dedect issue.
- ensure .net core runtime and AspNetCoreModule are installed And operating system restarted after installations.
- ensure your application pool .Net framework version is "No Managed Code" on iis.
- ensure that your application warming up properly. (open command prompt in directory where your application. type
dotnet yourapp.dll
and then press enter.) -
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 yourdotnet yourapp.dll
and it will workvar host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() .UseUrls("http://mywebsite.com") .Build();
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" />
MrBlue
Updated on June 17, 2022Comments
-
MrBlue almost 2 years
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); });
-
mukesh joshi about 5 yearsAs suggested above, the third step will give you clear picture if first 2 steps doesn't solve your problem.
-
MrBlue about 5 years1. 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.dll
-
levent about 5 yearscan you check log file is created under
.\logs\stdout