November Happy Hour will be moved to Thursday December 5th.

Multiple XHtmlString and PropertyFor throws: Cannot write to a closed TextWriter

Vote:
 

Hi,

We have site running EPiServer CMS 10.8.0 and get trouble when trying to render two or more XHtmlString properties via PropertyFor/DisplayFor.

This is the stacktrace given:

[ObjectDisposedException: Cannot write to a closed TextWriter.]
   System.IO.__Error.WriterClosed() +59
   System.IO.StringWriter.Write(String value) +38
   EPiServer.Util.Internal.AutoCompressString.WriteTo(TextWriter writer) +85
   EPiServer.Web.Mvc.Html.XhtmlStringExtensions.RenderFragment(IStringFragment fragment, HtmlHelper htmlHelper, UrlResolver urlResolver, IContentLoader contentLoader, TextWriter writer) +89
   EPiServer.Web.Mvc.Html.XhtmlStringExtensions.RenderXhtmlStringToWriter(HtmlHelper htmlHelper, XhtmlString xhtmlString, UrlResolver urlResolver, IContentLoader contentLoader, TextWriter writer) +256
   EPiServer.Web.Mvc.Html.XhtmlStringExtensions.RenderXhtmlString(HtmlHelper htmlHelper, XhtmlString xhtmlString) +48
   ASP.util_views_shared_displaytemplates_xhtmlstring_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in C:\Source\ActiveBranch\Minasidor3\Util\Views\Shared\DisplayTemplates\XhtmlString.ascx:4
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +117
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +79
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +250
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +75
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +79
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8753

If we instead render it via @Html.XhtmlSting(Model.Property) or just @Model.Property it works fine. So the workaround atm is to just do this:

x.FooterKontaktMain)> @Model.FooterKontaktMain

But it would be great if PropertyFor would work so does anyone have any idea on how to fix the problem?

#199091
Nov 15, 2018 8:48
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.