1

I use Entity Framework in a Blazor Server App to access data in an SQL Server database. The app runs fine in the IDE against the SQL Server database, but when I deploy to a test web server running IIS 10, it works until it pulls data from the database at which point it reports 'Service Unavailable' in the browser and I find errors in the Event Log on the server that say:

An ISAPI reported an unhealthy condition to its worker process. Therefore, the worker process with process id of '10940' serving application pool 'DefaultAppPool' has requested a recycle.

I have inspected the Event Log for the WAS type events, and nothing stands out as relevant. No errors that describe a cause are visible.

This is what I see in the browser after the process terminates:

Browser after Process terminates

I cannot find a cause that leads to a solution. I can break at the point where it will trigger this, and if I skip all subsequent code the web server will stay up.

These two lines can execute, and if I return from the second line it will result in termination:

 Account? account = _accountManagerService.GetAccount(Account);

 AspnetUser? user = _accountManagerService.GetUser(Account);

In those methods, the DB is accessed using lines like this:

account = context.Accounts.SingleOrDefault(c => c.AccountName.Equals(accountID));

If I skip the calls to the DBContext, the app will survive. If I make enough calls - not many, on the order of 2 to 5 or so - eventually the app will terminate after it returns from the code.

These calls do work and do return valid data, in fact, the entire process has run and returned the proper data, but once it is complete, the process terminates for no visible reason.

Why does this happen when I pull data from the SQL Server, and how do I resolve it? I have searched Google for more than a day now with nothing that resolves this. I have scoured the Event Logs to no avail. I have gathered Logs but nothing jumps out.

If I access data through one of the EF entities, that will lead to this condition. If I do not access the data, the site remains active.

It works on the development web server, but not when deployed to an actual web server.

What am I missing here, and what do I need to do to determine the root cause and thus hopefully a solution?

I have reviewed Logs, watched the code execute, searched google, fiddled with the Application Pool settings, reduced the amount of data pulled by the data context and pretty much everything I can think of.

I also tested against a totally separate SQL server instance with no change in behavior of the Webserver. I use SQL Server Authentication and have toggled 'Integrated Security' on and off with no change.

  • How do you authorize and can the App-pool user access the Db? – H H Mar 15 '23 at 21:39
  • Authorization is via SQL Server Authentication and I have toggled the Integrated Security with no impact. Since I get data back from the server before it crashes I can clearly interact with the server. Keep in mind this all works fine when run under the VS IDE, but fails only when I deploy to the server, which has a verified connection to the DB. It only fails after accessing the data, not during the effort. – BookTrakker Mar 15 '23 at 21:42
  • Not sure if you answered my question. What is the App pool user and is it listed in the SQL users ? – H H Mar 15 '23 at 21:57
  • Sorry, yes, the User listed under Identity for the App Pool is definitely able to access the DB. This makes sense, as I can get data back from the DB, but the app does not survive the process and is terminated. Whatever is happening takes place after accessing the DB. I can exit the method immediately after initial access and that will still result in the process terminating. I will add some code above to illustrate. – BookTrakker Mar 16 '23 at 01:00

1 Answers1

0

After hours of trying everything I could think of I decided to toggle the Enable 32-Bit Applications on the App Pool Advanced Settings. It appears to have resolved the problem and my app now remains operational after accessing the SQL Server DB via Entity Framework.

App Pool Advanced Settings

  • FWIW This issue is resolved and I ran straight into another very similar issue later in the code.... still characterizing this one so not yet clear on what is causing it. – BookTrakker Mar 16 '23 at 20:04