I want to include a Partial View in my Shared Layout template. This Partial View also has its own Controller and Model, e.g.
_MyPartialView.cs
@model MyModelClass
..some code.. @Model.SomeProperty
PartialController.cs
public PartialViewResult RenderMyPartial()
{
var model = new MyModelClass();
model.Initialize();
return PartialView("_MyPartialView", model);
}
_Layout (shared layout)
@Html.Action("RenderMyPartial", "PartialController")
The intention here is that the Layout page will call PartialController, which will go away and populate the model and return the Partial View which will bind to this model and render in the shared layout master template.
However when I run this I get the following error:
The controller for path '/XXX/' was not found or does not implement IController.
I've had a look around but was surprised that this doesn't seem to be a very common design pattern and wondered why? Any ideas?
Thanks Duncan