Rendering a child action using Html.RenderAction is broken

Posted by Community Admin on 04-Aug-2018 18:19

Rendering a child action using Html.RenderAction is broken

All Replies

Posted by Community Admin on 18-Jun-2015 00:00

Using the HtmlHelper method RenderAction within a view does not work in Sitefinity 8 "Pure" MVC mode. Here's the breakdown:

 

In the Controller:

[AcceptVerbs(HttpVerbs.Get)]

[ChildActionOnly]​

public ActionResult PrivacyPolicy()

 
    using (FluentSitefinity fluent = App.WorkWith())
    
        ContentItem contentItem = fluent.ContentItems()
            .Where(ci => ci.Title == "Privacy Policy" && ci.Status == ContentLifecycleStatus.Live)
            .Get()
            .FirstOrDefault();
  
        if (contentItem != null)
        
            return PartialView("_PrivacyPolicy", model:ResourceHelpers.GetLocalizedContent(contentItem.Content, true));
        
    
  
    return new HttpStatusCodeResult(500, "The privacy policy content could not be loaded.");

 

In the View:

@ Html.RenderAction("PrivacyPolicy", "MyControllerName");

 

Simple enough. I know that there isn't an error occurring in the child action, nor in the view because I can debug and step through no problem.   Unfortunately, this does not work. The widget fails to render and the following exceptions are generated in the log:

 

Timestamp: 6/18/2015 6:07:31 PM
 
Message: HandlingInstanceID: 01981c46-7c40-414b-831c-5d5d34af76c1
An exception of type 'System.Web.HttpException' occurred and was caught.
------------------------------------------------------------------------
06/18/2015 14:07:31
Type : System.Web.HttpException, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Message : Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.
Source : System.Web
Help link :
WebEventCode : 0
ErrorCode : -2147467259
Data : System.Collections.ListDictionaryInternal
TargetSite : Void ExecuteInternal(System.Web.IHttpHandler, System.IO.TextWriter, Boolean, Boolean, System.Web.VirtualPath, System.Web.VirtualPath, System.String, System.Exception, System.String)
HResult : -2147467259
Stack Trace :
   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.HttpServerUtilityWrapper.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)
   at ASP._Page_Frontend_Assembly_my assembly_Index_cshtml_my theme_cshtml.Execute() in e:\TEMP\vs\35d89ea4\b5299118\App_Web_index.cshtml#my theme.cshtml.11a9a948.k24trgqg.0.cs:line 0
   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.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
   at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at Telerik.Sitefinity.Mvc.ControllerWrapper.Execute()
   at Telerik.Sitefinity.Mvc.ControllerActionInvoker.ExecuteController(MvcProxyBase proxyControl)
   at Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Routing.DynamicUrlParamActionInvoker.ExecuteController(MvcProxyBase proxyControl)
 
Additional Info:
 
MachineName : my computer
TimeStamp : 6/18/2015 6:07:31 PM
FullName : Telerik.Sitefinity.Utilities, Version=8.0.5700.0, Culture=neutral, PublicKeyToken=b28c218413bdf563
AppDomainName : /LM/W3SVC/2/ROOT-2-130791241649155463
ThreadIdentity :
WindowsIdentity : my identity
Requested URL : http://localhost:60876/page/Index/3
    Inner Exception
    ---------------
    Type : System.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : Object reference not set to an instance of an object.
    Source : Telerik.Sitefinity
    Help link :
    Data : System.Collections.ListDictionaryInternal
    TargetSite : System.Web.Caching.CacheDependency GetCacheDependency(System.String, System.Collections.IEnumerable, System.DateTime)
    HResult : -2147467261
    Stack Trace :
           at Telerik.Sitefinity.Abstractions.VirtualPath.SitefinityVirtualPathProvider.GetCacheDependency(String virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
       at Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes.CacheDependentAttribute.GetCacheDependency(String virtualPath)
       at Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes.CacheDependentAttribute.OnResultExecuted(ResultExecutedContext filterContext)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.<BeginInvokeAction>b__20()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
       at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
       at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
       at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
       at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
       at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
       at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerAsyncWrapper.<>c__DisplayClassa.<EndProcessRequest>b__9()
       at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
       at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
       at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap(Action action)
       at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerAsyncWrapper.EndProcessRequest(IAsyncResult result)
       at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
 
 
 
Category: ErrorLog
 
Priority: 0
 
EventId: 9010
 
Severity: Warning
 
Title:Enterprise Library Exception Handling
 
Machine: my computer
 
App Domain: /LM/W3SVC/2/ROOT-2-130791241649155463
 
ProcessId: 3164
 
Process Name: C:\Program Files (x86)\IIS Express\iisexpress.exe
 
Thread Name:
 
Win32 ThreadId:7072
 
Extended Properties:
----------------------------------------

 

Posted by Community Admin on 23-Jun-2015 00:00

Hi Richard,

I have test you code and  Html.RenderAction() but this seems works fine (screenshot).

Please check the view returned and if the model has the correct/expected data.

In case this do not helps, i would recommend you to open a support ticket and provide the whole widget in order to test and inspect it more detailed.

There is issue with Html.RenderAction but it is fixed in version 7.0.

Please keep us informed about the results.

Regards,
Svetoslav Manchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 23-Jun-2015 00:00

Thank you for responding. I'm not sure what's going on now, but I can't replicate this exception today... I had reproduced it in three different variations on Thursday with the same exception every time, but today I can't. I'm thinking it may have been a caching issue of some form since the stack trace talks about the ​`System.Web.Caching.CacheDependency GetCacheDependency` at `Telerik.Sitefinity.Abstractions.VirtualPath.SitefinityVirtualPathProvider.GetCacheDependency`... if I can get it back in a state where it is throwing this exception again, I'll log a support ticket.

Posted by Community Admin on 24-Jun-2015 00:00

It was rendering last night with no problems and I thought I was losing my mind, but then when I came in this morning it's back to throwing this exception. It is intermittent, but when I can recreate the exception, I can continually recreate the exception. The only difference between the screen shot that you've provided and my code is that I'm passing a string as the model to the view. I'll log a support ticket.

Posted by Community Admin on 24-Jun-2015 00:00

I think this is actually related to caching and using the Html.RenderAction() method. After receiving the error again I disabled caching at the page level and the exception stopped occurring. Might help you to be able to reproduce it.

Posted by Community Admin on 24-Jun-2015 00:00

You should put in a ticket or bug directly to feedback.telerik.com/.../153 so this doesn't get forgotten! :)

Posted by Community Admin on 25-Jun-2015 00:00

I have a support case open.

Posted by Community Admin on 26-Jun-2015 00:00

Hello Richard,

As discussed this issue in the support ticket, considering this as bug I have logged it in the Feedback portal.

The workaround is cache disabling of the page or moving the view/s under Shared folder directly (not in sub folder/s), where this works fine.

Regards,
Svetoslav Manchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed