ASP.Net Core Web API in IIS - asp.net-core

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.

Related

issue running app on IIS server, keep getting app failed to start

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.

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.

Troubleshooting Web App process restarting

Our web app process is restarting regularly and we are unable to determine the reason.
When looking into Application Events (using the 'Diagnostics and solve problems' blade in the Azure Portal), there exists a bunch of the following Info logs by 'IIS AspNetCore Module'
Event ID 1005:
Failed to gracefully shutdown process '14040'.
Event ID 1001:
Application 'MACHINE/WEBROOT/APPHOST/myapplication__xxxx' started process '31628' successfully and is listening on port '17663'.
There is nothing fishy with general resource usage and nothing in our application logs.
What is the best way to troubleshoot the reason behind these process restarts?
EDIT 1:
After fiddling around with web logging in the Web App's Diagnostic Logs, I now get an error logged from W3SVC-WP after each restart, but the message is nonsense:
1<br/>5<br/>50000780
EDIT 2:
Event Id 2284 refers to this:
FailedRequestTracing module failed to write buffered events to log
file for the request that matched failure definition. No logs will be
generated until this condition is corrected. The problem happened at
least %1 times in the last %2 minutes. The data is the error.
I'm not sure if this could be related to our Diagnostic Logs configuration, but seems unlikely.
EDIT 3:
As per Brando Zhang's suggestion, I've used the Web App Crash Diagnoser extension and tried monitoring 2nd Chance Unhandled Exceptions on both my application process AND on w3wp, but nothing is dumped.
From how I understand it, 1st Chance Exceptions will not crash the process, so no need to monitor these.
Very likely application is crashing due to fatal exception and causing the restarts.
On Azure App Service platform.You can use the Diagnostics as a
Service (DaaS) to troubleshoot this
It can also do an analysis and tell you the root cause most of the time.More step by step infofrmation can be found on this msdn blog .Also refer tips for using crash diagnoser

Integrated app pool and virtual directories

I have MVC application that uses integrated app pool.
Under this MVC application, i have created a virtual directory that points to our file server location. This file server has some pdfs and custom images.
When we try to access the resources via virtual directory, I get the following error:
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred loading a configuration file: Failed to start monitoring changes to '\\nas2\CardDeck\web.config'.
Source Error:
[No relevant source lines]
Source File: \\nas2\CardDeck\web.config Line: 0
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
When I change the app pool to classic, i can access these resources just fine. What am i missing here?
Thanks
App pool was running under "NetworkService" identity.
I have changed it to a user account that has admin permissions on the box.
The thing that i still need to figure out is, why these were working under classic app pool and network service as the identity?

HTTP Error 404.0 - Not Found when accesing SVC service

I have REST service application which is hosted in an IIS 8 in a Windows 8 PC. When I request the service I am getting an error as follows ... HTTP Error 404.0 - Not Found.
Here is the detailed error message.
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Most likely causes:
•The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
Things you can try:
•Create the content on the Web server.
•Review the browser URL.
•Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://IP.com/Wining/RService.svc/general
Physical Path C:\inetpub\wwwroot\Wining\RService.svc\general
Logon Method Anonymous
Logon User Anonymous
Any help on this would be greatly appreciated.
There are myriads of possible causes. In general, the target resource at given URL is not found, so it may be simply missing, misconfigured, not started, etc. First - check the server logs, they usually contain more detailed information about the issue.
Also, please doublecheck that the service really is up and running. Connect to the www server and check it via localhost not ip.com.
I'm not an expert, but judging from the snippet you provided, it seems to be WCF service, the Handler: StaticFile seems very odd. It seems like the IIS misinterpretes your request as a StaticFile (a resource read from the disks and just passed-through without any further processing) which for me seems perfectly wrong.
You may have not installed the service properly, or have url mappings and/or handlers messed up, or you may even have NET/ASP framework not properly installed.. What have you installed first? .Net or IIS?
check similar questios, there are many.. for example:
WCF on IIS8; *.svc handler mapping doesn't work
HTTP 404 when accessing .svc file in IIS
I had to enable HTTP Activation in .NET Framework 4.5 Advanced Services > WCF Services (running on WIndows 2012) and after an IISReset it worked fine.