A possible reason for the .NET MVC "The view XXXX or its master was not found" error

“The view XXXX or its master was not found” error looks like that:

"The view 'XXXX' or its master was not found or no view engine supports the searched locations. 
The following locations were searched:
~/Areas/XXXX/Views/XXXX/XXXX.cshtml
~/Areas/XXXX/Views/XXXX/XXXX.vbhtml
~/Areas/XXXX/Views/Shared/XXXX.cshtml
~/Areas/XXXX/Views/Shared/XXXX.vbhtml
~/Views/XXXX/XXXX.cshtml
~/Views/XXXX/XXXX.vbhtml
~/Views/Shared/XXXX.cshtml
~/Views/Shared/XXXX.vbhtml"

and I recently had to deal with it, although I was 100% sure that my view was in the right place inside my MVC project.

The following solution is specific and applies only to projects where this static content is getting compiled inside the generated .dlls and is not hosted as a static files. After some searching I found out that I forgot the set the Build Action of the view to Embedded Resource. The default option when you create a new view is Content. You can set this option in the properties of the view in Visual Studio:

Build Action set to Embedded Resource in Visual Studio

I hope that this little tweak will save some precious time for you.

comments powered by Disqus