I have a rendering that displays fine on our CD servers, and in Experience Editor on some pages, but not on one page, where it's throwing an error. When I check the logs I see the following error:

    Exception: System.Web.HttpException
Message: Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.
Source: System.Web
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
   at System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter)
   at System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper htmlHelper, String actionName, String controllerName, Object routeValues)
   at ASP._Page_Areas_OrgControls_Views_List_AZList_cshtml.Execute() in c:\inetpub\wwwroot\Upgrade\Website\Areas\OrgControls\Views\List\AZList.cshtml:line 62
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

Nested Exception

Exception: System.Web.HttpUnhandledException
Message: An unhandled exception occurred.
Source: Sitecore.Mvc
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args)
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.Process(ExceptionArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
   at Sitecore.Mvc.Filters.PipelineBasedRequestFilter.OnException(ExceptionContext exceptionContext)
   at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

The rendering code that is triggering the error is RenderAction here:

<div class="A-Z-DirList">
            if (Model.Letters != null)
                foreach (char l in AZModel.ALPHABET)
                    if (Model.Letters.Contains(l))
                        <h2 class="dirLetter" id="@l" name="@l">@Char.ToUpper(l)</h2>
                        foreach (var item in Model.Items.Where(x => x.Name.StartsWith(l.ToString(), StringComparison.CurrentCultureIgnoreCase)).OrderBy(x => x.Name))
                            Html.RenderAction(item.View, item.Controller, new { Model = item.Model });

I'm not quite sure what's going on here and why it's working on some pages but not others. Here is the controller code for the rendering:

public ActionResult AZList()
            if (Sitecore.Context.PageMode.IsExperienceEditorEditing && String.IsNullOrEmpty(RenderingContext.Current.Rendering.Parameters["Item Types"]))
                return Content("<div><h3>Use the component properties for this widget to select the item types you wish to display</h3></div>");

            var includeSearch = "0";
            if (!(String.IsNullOrEmpty(RenderingContext.Current.Rendering.Parameters["Show Search Field"])))
                includeSearch = RenderingContext.Current.Rendering.Parameters["Show Search Field"].ToString();

            var model = new AZModel();
            model.searchForm = includeSearch == "1" ? true : false;

            var orgRoot = Org.Utility.OrgUtils.GetRoot(Sitecore.Context.Item);
            var allItems = new List<Sitecore.Data.Items.Item>();

            // determine what kinds of items are in this list from the rendering parameters
            var allItemTypes = RenderingContext.Current.Rendering.Parameters["Item Types"];

            // if somehow nothing was selected, bail out
            if (String.IsNullOrEmpty(allItemTypes)) return null;

            var itemTypes = allItemTypes.Split('|');
            var OrgRegion = orgRoot.Parent.Axes.GetDescendants().Where(x => x.Name.StartsWith("All ")).FirstOrDefault();
            var queryOrg = "/sitecore/content/Orgs//*[@@id='" + orgRoot.ID.ToString() + "']//*[@@templateid='";
            var queryRegion = "|/sitecore/content/Orgs//*[@@id='" + OrgRegion.ID.ToString() + "']//*[@@templateid='";
            var queryGlobal = "|/sitecore/content/Orgs/All Orgs//*[@@templateid='";
            for (var i = 0; i < itemTypes.Length; i++)
                var typeId = itemTypes[i];

                var guid = new Guid(typeId);
                var id = ID.Parse((Guid)guid);
                var typeInfo = Sitecore.Context.Database.GetItem(id);

            if (typeInfo == null)
                    logger.Info("Could not find item with ID '" + typeId + "'");

                var squery = queryOrg + typeInfo["Data Template"] + "']";
                squery += queryRegion + typeInfo["Data Template"] + "']";
                squery += queryGlobal + typeInfo["Data Template"] + "']";

                // get all the items of the given typeId beneath the root
                var templateItems = Sitecore.Context.Database.SelectItems(squery).ToList();

                // see if there are any items
                if (templateItems.Any())
                    // see what controller & view to use
                    var controller = typeInfo["Controller Name"];
                    var view = typeInfo["View Name"];

                    logger.Info("Controller: " + controller + ", View: " + view);

                    string nameField = "Title";

                    // add them to the model
                    model.Items.AddRange(templateItems.Select(x => new ListItem
                            Model = x,
                            Controller = controller,
                            Name = x[nameField],
                            View = view

            // iterate through items to see what letters we should activate
            foreach(char c in AZModel.ALPHABET)
                // select from allItems where name/title/whatever toLower starts with c
                if(model.Items.Where(x => x.Name.ToLower().StartsWith(c.ToString())).Any())
                    // if any, add this character to the string in our model
                    model.Letters += c;

            model.Title = RenderingContext.Current.Rendering.Parameters["Title"];
            model.Description = RenderingContext.Current.Rendering.Parameters["Content"]; ;

            return PartialView(model);
  • Can you share the code for the controller that is responsible to call the view? Sep 4 '19 at 12:24
  • It looks like you are rendering a view which is attempting to render a view, it could be an infinite loop based on your controller code. As @HishaamNamooya suggest, please share controller code as well. Sep 4 '19 at 12:35
  • I've updated it with the controller code. Sep 4 '19 at 12:42
  • 5 second analysis: Sitecore.Context.PageMode.IsExperienceEditorEditing && String.IsNullOrEmpty(RenderingContext.Current.Rendering.Parameters["Item Types"]) should be Sitecore.Context.PageMode.IsExperienceEditorEditing || String.IsNullOrEmpty(RenderingContext.Current.Rendering.Parameters["Item Types"])
    – Mark Cassidy
    Sep 4 '19 at 12:55
  • 1
    If you have [HttpPost] or [HttpGet], try to remove it and see Sep 4 '19 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.