Hi @Rijwan Ansari ,
I think the displayed error message in .NET 6 is not correct. I had the same issue a few days ago.
The issue was, my startup project was chosen wrong.
Fixing:
I fixed it by setting the web project as a startup. You can try changing the startup project into the correct one.