issue running app on IIS server, keep getting app failed to start - asp.net-core

IIS 10 ASP.NET Core app failed to start
Getting error HTTP Error 500.30 - ASP.NET Core app failed to start when i launch the web app. In event viewer i have:
Application '/LM/W3SVC/3/ROOT' with physical root 'C:\inetpub\wwwroot\MarCRM_Pro' has exited from Program.Main with exit code = '1'. Please check the stderr logs for more information.
and
Application '/LM/W3SVC/3/ROOT' with physical root 'C:\inetpub\wwwroot\MarCRM_Pro' failed to load coreclr. Exception message:
CLR worker thread exited prematurely
The app on Visual Studio 2019 works when i run it then i publish it to a folder and copy that to the IIS server.
hopefully i can find some answer soon, i have been trying different things found by googling but so far no luck.

I was able to find a fix to this by changing in web.config file.
In the web.config file had to change the hostingModel="OutOfProcess" from "InProcess"
Post where i was able to find this fix.
.NET Core 3.0 and IIS: HTTP Error 500.30 - ANCM In-Process Start Failure: failed to load coreclr
Thanks for your input guys.

Related

ASP.Net Core Web API in IIS

I'm trying to add an API to IIS. The API (via Swagger) runs fine locally. To rule out anything in my API I built the basic Weather API one and I get the same error.
App Log:
Application '/LM/W3SVC/1/ROOT/WeatherAPI' with physical root 'C:\inetpub\wwwroot\Weather' failed to load coreclr. Exception message:
CLR worker thread exited prematurely
Application '/LM/W3SVC/1/ROOT/WeatherAPI' with physical root 'C:\inetpub\wwwroot\Weather' hit unexpected managed exception, exception code = '0xe0434352'. Please check the stderr logs for more information.
Error 0xe0434352 is so generic as to be of no use.
I see others have had similar issues (some of which are on StackOverflow) but none resolve the issue.
It's being published as: Release/.Net 6.0/Self-Contained/win-x64.
The AppPool is "No Managed Code"/Integrated Pipedline.

HTTP Error 500.30 (Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The system cannot find the file specified.)

I am trying to deploy the asp.net core Web API to the IIS. This application works perfectly fine on the Visual studio and also when I run the dll using the dotnet command. This application has the certificate for signing the JWT token. After deploying the application to IIS I am getting "HTTP Error 500.30 - ANCM In-Process Start Failure" and I checked the windows log and error message is
Host terminated unexpectedly.
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The system cannot find the file specified.at Internal.Cryptography.Pal.CertificatePal.FilterPFXStore(Byte[] rawData, SafePasswordHandle password, PfxCertStoreFlags pfxCertStoreFlags)......
I checked the file path and file name everything is correct but some reason IIS is not able to load find the certificate file. Also, I checked the permission and it also looks good. Not sure why I am getting this error message
Also, I ran the same application dll file using the dotnet run command where IIS is pointing to but I am not getting any error. I am getting this error only after deployng to IIS.
On startup.cs file and configuration method I am getting error on this line.
var cert = new X509Certificate2("test_cert.pfx", pwdFrmVault);
I after searching for this error and googling, this solution worked for me. IIS Manager->application pool -> advanced settings ->Under Process model, Load User Profile to true. More detail on link

HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process

I hosted a .NET CORE 3.0(razor pages) application which was running fine after few days for no reason it was just displaying HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process Common solutions to this issue:
Select a different application pool to create another in-process application., then I found this solution HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process that fixed it by deleting .vs Folder, On Saturday morning I downloaded the new visual studio update 16.6.0. This morning the application running on the server started showing the same error, without any changes to the it, I followed the same step I used to fix it earlier but still didn't fix it, please is there any other solution to fix this? Because right now everything is working fine in my local machine. Thanks in advance.

Application '/LM/W3SVC/1/ROOT/' with physical root '' failed to load clr and managed application

My Web API runs OK most of the time in IIS v.10 on Windows Server 2016. However, an error occurs from time to time and I can't figure out the error source or cause. The corresponding Windows Logs/Application error log record is as follows
Application '/LM/W3SVC/1/ROOT/MyWebAPI' with physical root '....\MyWebAPI\' failed to load clr and managed application.
Managed server didn't initialize after 120000 ms.
Process Id: 4840.
File Version: 12.2.19169.6. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: e7f262e33108e92fc8805b925cc04b07d254118b
The error results in HTTP Error 500.30 - ANCM In-Process Start Failure on the client side. After that, MyWebAPI stops working and I have to recycle MyWebAPI application pool manually.
Can anybody help, please?
ACM 500.30 means something wrong with the startup.
for more info -> https://learn.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-3.1#50030-in-process-startup-failure
If you are using 3rd party services like KeyVault etc then surround them with try-catch and log error in the logger.
you can use event viewer for debugging.
https://www.happycoder.gr/blog/aspnet-core-20-event-viewer-application-logging/
I got the same error when I published my .net core 3.1 project.
You can get this error if your server is win-x64 and you published to win-x86. If this is the case, you must change the target runtime to win-x64.

How to publish a asp.net web core application on own hosting windows

I have a taken a windows hosting that can run web core 2 applications. I have published first the application to a folder on my pc and then moved the files to a folder on the hosted web site. When I access the folder via http I get the following error message:
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
This is a basic application without database, it's the "Hello World" empty Template of Visual Studio. I did this for a test.
The web provider says it does not depend from them. I have no way to know what is going wrong. Any idea?
You can read this blog http://dotnet4hosting.asphostportal.com/post/How-to-Publish-ASPNET-Core-2.aspx. It seems that you havent published your application properly.
Based on my experience, to resolve above error, you need to publish the website/project as a self-contained application. In order to publish it as a self-contained application, please add this to the csproj folder.
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<RuntimeIdentifiers>win7-x64;win7-x86;ubuntu.16.04-x64;</RuntimeIdentifiers>
<SuppressDockerTargets>True</SuppressDockerTargets>
</PropertyGroup>
Hope this help!