An unhandled exception occurred while processing the request "The view 'ViewName' was not found. The following locations were searched"

Question: How do you solve for the error in AspNet 6 MVC "An unhandled exception occurred while processing the request "The view 'ViewName' was not found. The following locations were searched".

This error seems to be not correct, there is a View with the View Name in the directory. Why can't Visual Studio 2022 find the View? I can see it.

Answer: Absolutely, the Compiler is correct, the View cannot be found, take a clear look at the View in question. You will find out that it has a subclass nested.

View Could Not Be Found in MVC

At some point when you copied and pasted the same View in order to create a new one, the Compiler or the Microsoft Build Engine ended up changing one View to be more like a Razor Page. 

This is most likely to happen when you copy and paste the same View and you notice no errors even when the Views have the same names. The reason why the MS Build or the IntelliSense did not throw an error even when the Views seem to have the same is, one of the Views got changed. 


Edit this Article
MVC AspNet 6 e-book MVC Razor .NET 6 published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.
Your Session is Ending
Login to Continue


© 2021 - ErnesTech - Privacy