Basically I've just created an Area in my ASP.NET MVC4 application. It all works great etc, however when I want to return a PartialView as shown below:
return PartialView("_ImportSessionsTable", viewModel);
(not that the above call is called from the area(admin) view) I get the following error:
The partial view '_ImportSessionsTable' was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/ImportSessions/_ImportSessionsTable.aspx
~/Views/ImportSessions/_ImportSessionsTable.ascx
~/Views/Shared/_ImportSessionsTable.aspx
~/Views/Shared/_ImportSessionsTable.ascx
~/Views/ImportSessions/_ImportSessionsTable.cshtml
~/Views/ImportSessions/_ImportSessionsTable.vbhtml
~/Views/Shared/_ImportSessionsTable.cshtml
~/Views/Shared/_ImportSessionsTable.vbhtml
The thing is: as far as I can see it isn't looking for the view in the area folder (admin) which is where I have the view stored. How can I get it to look there? Whenever I call return View();
it works fine so it's only when I specify the view as a string.
How can I get it to look there?
You could specify the full location of the partial to be rendered:
return PartialView("~/Areas/Admin/Views/ImportSessions/_ImportSessionsTable.cshtml", viewModel);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With