skip to Main Content

I’ve created a new Web Server API project in Visual Studio 2022 using .NET 8.0. Automatically, the WeatherForecast controller is generated. After compiling and publishing without making any changes, I configured the project on IIS, and everything works fine.

Later, I changed the target platform to x86.
enter image description here

I compiled and published again without receiving any errors. I also tried setting the runtime target to x86 and x64.
enter image description here

However, after configuring the project on IIS, I’m getting a 500.30 error when trying to access the created controller.
enter image description here

When I run the project in Debug/Release mode directly from Visual Studio, everything works fine.

After enabling logging, I receive this error:

Event Log: ‘Application ‘/LM/W3SVC/3/ROOT’ with physical root ‘C:inetpubwwwrootrestapi’ hit unexpected managed exception, exception code = ‘0xe0434352′. Please check the stderr logs for more information.’
End Event Log Message.

Can someone help me resolve this issue? Thanks in advance for any suggestions.

2

Answers


  1. I suggest you to look at the event viewer to try to identify the exact reason.
    HTTP Error 500 is caused by an exception at run-time. So there could be many reason. Sometimes, you must look at the 2 or 3 events before till 2 or 3 events after.

    In order, I would search on:

    • The runtime. Is it well set up on the server. You have to install the
      bundle
      (https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-aspnetcore-8.0.4-windows-hosting-bundle-installer)
    • The necessary libraries. If you have published the application,
      everything is located in the binpublish folder.
    • The permissions that are affected to the folder. To be sure, you can add ‘Everyone’ to the list of authorized users, and give Read/Write permission. It the problem is solved, you will have to give the exact permissions which are determined by the Application Pool that serves this web site.

    Also, if you didn’t find at this stage, you can start the .exe file of your application instead of IIS which will run in a console and will show you the exceptions if any. You must stop the web site before running the exe.

    Good luck.

    Login or Signup to reply.
  2. Expand my comment a little bit.

    You probably already know that ASP.NET Core by default uses in-process hosting mode. IIS by default creates 64 bit worker processes (w3wp.exe) which in turn loads the 64 bit ASP.NET Core module (ANCM, aka aspnetcorev2.dll).

    ANCM loads Any CPU/x64 bits without problems, as bitness matches. However, you intentionally changed your artifacts to 32 bit, which cannot be loaded in 64 bit processes. That’s the cause of the 500.30 error.

    There is usually no reason to switch to 32 bit, but if you do have a need you have to also change IIS application pool to run in 32 bit mode, so that it creates 32 bit worker process with 32 bit ANCM. That’s how you found the error was resolved.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search