I had the same issue when I was setting up the project on a new server, in my case ofcourse the system was missing the hosting bundle.
I installed Hosting Bundle 8.0 and tried restarting IIS server, it did not work.
As the application hosted was in .Net 6 I had to install Hosting Bundle 6.0 as well. After restarting IIS, the issue was resolved.