goin back to my 'routes' - issue with partialviews and areas??
Asked Answered
S

1

0

i've hit another brick wall today with jquery generated partialviews when located within areas. it's a bit baffling as i have a number of partialviews located under ~/areas/administration/views/shared which all get rendered fine if included inside a normal view. However, if i invoke any of the same partial views via ajax, the controller action runs fine but i get an error. on closer inspection, the error reveals itself to be due to the partialview in question not being found by the view engine (ascx). basically, the console reports that all the 'normal' view locations were searched but that the engine was unable to find the view in question.

I'm wondering if it's a routing issue, tho it seems unlikely. has anyone else experienced an issue with partialviews inside areas when invoked via jquery ajax?? as i say, it's especially baffling given that the same partial renders just fine if included 'inline' in a standard view that 'lives' under the same areas folder.

thoughts welcome..

Simarouba answered 28/7, 2011 at 23:9 Comment(2)
How are you naming your partial views? and are you returning a PartialView() view result?Tod
lomaxx - here's the call: public PartialViewResult RecipeList(int ingredientId) { var recipes = _recipeService.All.Where(x => x.IngredientId == ingredientId); return PartialView("RecipeList", recipes); } i had also tired it with the fully qualified path - still no luck!!Simarouba
S
0

Ok,

I got this fixed after a little brain-storming. Basically, the problem was related to the fact that I was referencing both the 'root' of the site and the 'areas' namespaces from the core web.config file, ie:

<pages>
  <namespaces>
    <add namespace="ABC.Web.Site.Controllers" />
    <add namespace="ABC.Web.Site.Models" />
    <add namespace="ABC.Web.Site.Models.ViewModels" />
    <add namespace="ABC.Web.Site.Areas.Administration.Controllers" />
    <add namespace="ABC.Web.Site.Areas.Administration.Models" />
    <add namespace="ABC.Web.Site.Areas.Administration.Models.ViewModels" />
  </namespaces>
</pages>

moving each set to their own web.config under the views folder sorted the issue: ie.:

root/views/web.config:

<pages>
  <namespaces>
    <add namespace="ABC.Web.Site.Controllers" />
    <add namespace="ABC.Web.Site.Models" />
    <add namespace="ABC.Web.Site.Models.ViewModels" />
  </namespaces>
</pages>

areas/views/web.config:

<pages>
  <namespaces>
    <add namespace="ABC.Web.Site.Areas.Administration.Controllers" />
    <add namespace="ABC.Web.Site.Areas.Administration.Models" />
    <add namespace="ABC.Web.Site.Areas.Administration.Models.ViewModels" />
  </namespaces>
</pages>

bliss...

Simarouba answered 29/7, 2011 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.