I have a doc type that allows users to pick alerts for pages using a multi node treepicker. Alerts are instances of another document type. Alerts don't have their own page so I wanted to use their selected template like a partial. What I want to do is something like:
var alertIds = Model.Content.GetPropertyValue("alert");
List<umbraco.NodeFactory.Node> alerts = new List<umbraco.NodeFactory.Node>();
foreach (var alertId in alertIds.ToString().Split(','))
{
alerts.Add(new umbraco.NodeFactory.Node(int.Parse(alertId)));
}
Then as an example I could do:
library.RenderTemplate(alerts[0].Id)
I wanted to do it this way because I like the idea that the templates can be chosen in Umbraco
and just know how to render themselves, rather than creating a partial in my MVC project and handling it on that side. However, I run into the following error:
"Error rendering template with id 1128: 'System.InvalidOperationException: A single instance of controller 'Umbraco.Web.Mvc.RenderMvcController' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller for each request.\r\n at System.Web.Mvc.ControllerBase.VerifyExecuteCalledOnce()\r\n at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)\r\n at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)\r\n at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)\r\n at Umbraco.Web.Mvc.UmbracoMvcHandler.ExecuteUmbracoRequest()\r\n at Umbraco.Web.Templates.TemplateRenderer.RenderUmbracoRequestToString(RequestContext requestContext)\r\n at Umbraco.Web.Templates.TemplateRenderer.ExecuteTemplateRendering(TextWriter sw, PublishedContentRequest contentRequest)\r\n at Umbraco.Web.Templates.TemplateRenderer.Render(StringWriter writer)\r\n at umbraco.library.RenderTemplate(Int32 PageId, Int32 TemplateId)' "
Thanks in advance for checking this out!