I have an Area called Admin. The folder structure in Visual Studio is this:
Areas
Admin
Controllers
Views
I have a controller called AccountController in which I have a Action called Verify. I have this line of code in this action:
return View("EmailVerificationComplete");
But, I get this error:
The view 'EmailVerificationComplete' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Account/EmailVerificationComplete.aspx
~/Views/Account/EmailVerificationComplete.ascx
~/Views/Shared/EmailVerificationComplete.aspx
~/Views/Shared/EmailVerificationComplete.ascx
~/Views/Account/EmailVerificationComplete.cshtml
~/Views/Account/EmailVerificationComplete.vbhtml
~/Views/Shared/EmailVerificationComplete.cshtml
~/Views/Shared/EmailVerificationComplete.vbhtml
Why is this? Why does MVC not know to look in the Views folder relative to the Admin area?
How do I solve this?
Thanks,
Sachin
Best Answer
Because your
AccountController
is not inside theAdmin
area. It's probably in~/Controllers/AdminController.cs
so by convention ASP.NET MVC will look in~/Views/Shared
or~/Views/Account
for its corresponding views.