Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to return partial view from area

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.

like image 277
Jordan Axe Avatar asked Oct 20 '13 13:10

Jordan Axe


1 Answers

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);
like image 54
Darin Dimitrov Avatar answered Sep 28 '22 02:09

Darin Dimitrov