public override object Execute(ParameterList parameters, FunctionContextContainer context) { var result = new XhtmlDocument(); var functionCall = new XElement(Composite.Core.Xml.Namespaces.Function10 + "function", new XAttribute("name", "Composite.Forms.RendererControl")); BaseRuntimeTreeNode paramNode = null; foreach (var parameterName in parameters.AllParameterNames) { try { if (parameters.TryGetParameterRuntimeTreeNode(parameterName, out paramNode)) { functionCall.Add(paramNode.Serialize()); } } //Ignore catch { } } result.Body.Add( new XElement(Namespaces.AspNetControls + "form", functionCall)); return result; }
public override bool TryConvert(object value, Type targetType, out object targetValue) { Verify.ArgumentNotNull(value, "value"); if (targetType == typeof(XhtmlDocument) && value is XElement) { XElement valueCasted = (XElement)value; targetValue = new XhtmlDocument(valueCasted); return(true); } if (targetType == typeof(XElement) && value is XhtmlDocument) { XhtmlDocument valueCasted = (XhtmlDocument)value; targetValue = valueCasted.Root; return(true); } if (targetType == typeof(XNode) && value is XhtmlDocument) { XhtmlDocument valueCasted = (XhtmlDocument)value; targetValue = valueCasted.Root; return(true); } targetValue = null; return(false); }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { string markup; if (C1File.Exists(this.FilePath)) { markup = C1File.ReadAllText(this.FilePath); } else { // someone deleted the feature file, but that won't stop us! XhtmlDocument template = new XhtmlDocument(); template.Head.Add(""); template.Body.Add(""); markup = template.ToString(); } this.Bindings.Add("FeatureName", this.FeatureName); this.Bindings.Add("Markup", markup); if (Path.GetExtension(this.FilePath)==".html") { this.documentFormActivity1.FormDefinitionFileName = @"\Administrative\PageTemplateFeature\EditVisual.xml"; } else { this.documentFormActivity1.FormDefinitionFileName = @"\Administrative\PageTemplateFeature\EditMarkup.xml"; } }
public static void ConvertActionLinks(XhtmlDocument document, RequestContext requestContext, RouteCollection routeCollection) { var actionLinks = GetLinkContainingAttributes(document).Where(a => IsRawActionLink((string) a)); foreach (var linkAttr in actionLinks) { string url = ConvertActionLink((string)linkAttr, requestContext, routeCollection); if (url != null && !url.StartsWith("/?")) { linkAttr.Value = url; } } }
/// <exclude /> public Markup(XElement content, FunctionContextContainer functionContextContainer) { if(content.Name.LocalName == "html") { InnerContent = content; } else { var document = new XhtmlDocument(); document.Body.Add(content); InnerContent = document.Root; } _functionContextContainer = functionContextContainer; }
/// <summary> /// Parses an xhtml fragment of into an XhtmlDocument. /// </summary> /// <param name="fragment"></param> /// <returns></returns> public static XhtmlDocument ParseXhtmlFragment(string fragment) { if (string.IsNullOrEmpty(fragment)) { return(new XhtmlDocument()); } var nodes = new List <XNode>(); using (var stringReader = new StringReader(fragment)) { var xmlReaderSettings = new XmlReaderSettings { IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Parse, MaxCharactersFromEntities = 10000000, XmlResolver = null, ConformanceLevel = ConformanceLevel.Fragment // Allows multiple XNode-s }; var inputContext = FragmentContainsHtmlEntities(fragment) ? GetXhtmlFragmentParserContext() : null; using (var xmlReader = XmlReader.Create(stringReader, xmlReaderSettings, inputContext)) { xmlReader.MoveToContent(); while (!xmlReader.EOF) { XNode node = XNode.ReadFrom(xmlReader); nodes.Add(node); } } } if (nodes.Count == 1 && nodes[0] is XElement && (nodes[0] as XElement).Name.LocalName == "html") { return(new XhtmlDocument(nodes[0] as XElement)); } var document = new XhtmlDocument(); document.Body.Add(nodes); return(document); }
/// <summary> /// Parses a serialized xhtml document and returns XhtmlDocument. /// </summary> /// <param name="xhtml">xhtml to parse.</param> /// <returns>XhtmlDocument representing the supplied string</returns> public new static XhtmlDocument Parse(string xhtml) { var doc = new XhtmlDocument(XDocument.Parse(xhtml)); List <XElement> sourceWhitespaceSensitiveElements = GetWhitespaceSensitiveElements(doc); if (sourceWhitespaceSensitiveElements.Any()) { XhtmlDocument docWithWhitespaces = new XhtmlDocument(XDocument.Parse(xhtml, LoadOptions.PreserveWhitespace)); List <XElement> fixedWhitespaceSensitiveElements = GetWhitespaceSensitiveElements(docWithWhitespaces); for (int i = 0; i < sourceWhitespaceSensitiveElements.Count; i++) { sourceWhitespaceSensitiveElements[i].ReplaceWith(fixedWhitespaceSensitiveElements[i]); } } return(doc); }
private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs e) { string name = this.GetBinding<string>("Name"); string editorType = this.GetBinding<string>("EditorType"); string filename = PageTemplateFeatureFacade.GetNewPageTemplateFeaturePath(name, editorType); var template = new XhtmlDocument(); template.Head.Add(""); template.Body.Add(new XElement(Namespaces.Xhtml + "p", "")); C1File.WriteAllText(filename, template.ToString()); this.CloseCurrentView(); this.RefreshRootEntityToken(); this.ExecuteAction(PageTemplateFeatureEntityToken.BuildFeatureEntityToken(name), new WorkflowActionToken(typeof(EditPageTemplateFeatureWorkflow))); }
public override bool TryConvert(object value, Type targetType, out object targetValue) { Verify.ArgumentNotNull(value, "value"); if (targetType == typeof(XhtmlDocument) && value is XElement element) { targetValue = new XhtmlDocument(element); return(true); } if ((targetType == typeof(XElement) || targetType == typeof(XNode)) && value is XhtmlDocument document) { targetValue = document.Root; return(true); } targetValue = null; return(false); }
private void PageOnPreRender(Page aspnetPage, IPage page) { bool emitMenuTitleMetaTag = !page.MenuTitle.IsNullOrEmpty(); bool emitUrlTitleMetaTag = !page.UrlTitle.IsNullOrEmpty(); if ((emitMenuTitleMetaTag || emitUrlTitleMetaTag) && UserValidationFacade.IsLoggedIn()) { var xhtmlDocument = new XhtmlDocument(); PageRenderer.AppendC1MetaTags(page, xhtmlDocument); if (aspnetPage.Header != null) { string xml = string.Join(string.Empty, xhtmlDocument.Head.Nodes().Select(node => node.ToString())); aspnetPage.Header.Controls.Add(new Literal {Text = xml}); } } }
public static void ControllerLinksToC1PageLinks(XhtmlDocument document, string baseControllerUrl) { // Converting links like // "~/<controller name>/action" to "<page url>/action // // Also for function with parameters: f.e.: // Page url "/Home/BookStore/Fantasy", // and controller "books" with a predefined parameter "fantasy", it should replace // "/books[/...]" with "/Home/BookStore[/....]" which require the url part comparison below: string pageUrl = GetCurrentC1PageUrl(); var replacementRule = GetReplacementRule(pageUrl, baseControllerUrl); // Replacing action links var linkAttributes = GetLinkContainingAttributes(document); foreach (var linkAttr in linkAttributes) { linkAttr.Value = ReplacePrefix(linkAttr.Value, replacementRule); } }
private static List<XElement> GetWhitespaceSensitiveElements(XhtmlDocument doc) { return doc.Descendants().Where(node => node.Name.Namespace == Namespaces.Xhtml && (node.Name.LocalName == "pre" || node.Name.LocalName == "textarea")).ToList(); }
private void ProcessDocument(XhtmlDocument document, ParameterList parameters) { string baseControllerUrl = GetBaseMvcRoute(parameters); ActionLinkHelper.ControllerLinksToC1PageLinks(document, baseControllerUrl); }
/// <summary> /// Parses a serialized xhtml document and returns XhtmlDocument. /// </summary> /// <param name="xhtml">xhtml to parse.</param> /// <returns>XhtmlDocument representing the supplied string</returns> public new static XhtmlDocument Parse(string xhtml) { var doc = new XhtmlDocument(XDocument.Parse(xhtml)); List<XElement> sourceWhitespaceSensitiveElements = GetWhitespaceSensitiveElements(doc); if (sourceWhitespaceSensitiveElements.Any()) { XhtmlDocument docWithWhitespaces = new XhtmlDocument(XDocument.Parse(xhtml, LoadOptions.PreserveWhitespace)); List<XElement> fixedWhitespaceSensitiveElements = GetWhitespaceSensitiveElements(docWithWhitespaces); for (int i = 0; i < sourceWhitespaceSensitiveElements.Count; i++) { sourceWhitespaceSensitiveElements[i].ReplaceWith(fixedWhitespaceSensitiveElements[i]); } } return doc; }
public XhtmlDocument Render(IDataReference dataReferenceToRender) { if (!dataReferenceToRender.IsSet) { return new XhtmlDocument(); } IData dataToRender; if (dataReferenceToRender.ReferencedType == typeof(IPage)) { dataToRender = DataFacade.TryGetDataByUniqueKey<IPage>(dataReferenceToRender.KeyValue); if (dataToRender == null) { return new XhtmlDocument(); } } else { dataToRender = dataReferenceToRender.Data; } string markup = _templateString; string labelEncoded = ""; string keyValue = ""; if (_labelHasToBeEvaluated) { labelEncoded = HttpUtility.HtmlEncode(dataToRender.GetLabel()); } if (_idHasToBeEvaluated) { keyValue = dataReferenceToRender.KeyValue.ToString(); } var parameters = new object[2 + _fieldNames.Count]; parameters[0] = labelEncoded; parameters[1] = keyValue; // Getting field values for (int i = 0; i < _fieldNames.Count; i++) { Type referenceType = dataReferenceToRender.ReferencedType; var propertiesMap = _reflectionCache.EnsureValue(referenceType, () => new Hashtable<string, PropertyInfo>()); string fieldName = _fieldNames[i]; PropertyInfo propertyInfo; if (!propertiesMap.TryGetValue(fieldName, out propertyInfo)) { lock (propertiesMap) { if (!propertiesMap.TryGetValue(fieldName, out propertyInfo)) { Type type = referenceType; while (type != null && type != typeof(object)) { propertyInfo = type.GetProperty(fieldName); if (propertyInfo != null) { propertiesMap.Add(fieldName, propertyInfo); break; } if (type.GetInterfaces().Length > 0) { type = type.GetInterfaces()[0]; } } if (propertyInfo == null) { LoggingService.LogWarning(LogTitle, "Failed to find property '{0}' on type '{1}'" .FormatWith(fieldName, referenceType.FullName)); propertiesMap.Add(fieldName, null); } } } } string value = String.Empty; if (propertyInfo != null) { value = (propertyInfo.GetValue(dataToRender, new object[0]) ?? String.Empty).ToString(); } switch (_renderingEncoding) { case XhtmlRenderingEncoding.None: break; case XhtmlRenderingEncoding.AttributeContent: value = HttpUtility.HtmlAttributeEncode(value); break; case XhtmlRenderingEncoding.TextContent: value = HttpUtility.HtmlEncode(value); break; default: throw new NotImplementedException("Unexpected XhtmlRenderingEncoding value"); } parameters[2 + i] = value; } string evaluatedMarkup = string.Format(markup, parameters); XElement bodyMarkup = XElement.Parse(evaluatedMarkup); XhtmlDocument xhtmlDocument = new XhtmlDocument(); xhtmlDocument.Body.Add(bodyMarkup.Nodes()); return xhtmlDocument; }
private static XhtmlDocument ExecuteNestedFunctions(XhtmlDocument document, FunctionContextContainer functionContextContainer) { PageRenderer.ExecuteEmbeddedFunctions(document.Root, functionContextContainer); return document; }
private void MergeHeadSection(XhtmlDocument xhtmlDocument, HtmlHead headControl, IXElementToControlMapper controlMapper) { xhtmlDocument.MergeToHeadControl(headControl, controlMapper); // handling custom master page head control locally - removing it if a generic meta description tag was in the document if (headControl.Controls.OfType<HtmlMeta>().Any(f=>f.Name=="description")) { var existingDescriptionMetaTag = headControl.Controls.OfType<DescriptionMetaTag>().FirstOrDefault(); if (existingDescriptionMetaTag != null) { headControl.Controls.Remove(existingDescriptionMetaTag); } } }
private static List <XElement> GetWhitespaceSensitiveElements(XhtmlDocument doc) { return(doc.Descendants().Where(node => node.Name.Namespace == Namespaces.Xhtml && (node.Name.LocalName == "pre" || node.Name.LocalName == "textarea")).ToList()); }
private void NormalizeAspNetForms(XhtmlDocument xhtmlDocument) { // If current control is inside <form id="" runat="server"> tag all <asp:forms> tags will be removed from placeholder bool isInsideAspNetForm = false; var ansestor = this.Parent; while (ansestor != null) { if (ansestor is HtmlForm) { isInsideAspNetForm = true; break; } ansestor = ansestor.Parent; } if (!isInsideAspNetForm) { return; } List<XElement> aspNetFormElements = xhtmlDocument.Descendants(Namespaces.AspNetControls + "form").Reverse().ToList(); foreach (XElement aspNetFormElement in aspNetFormElements) { aspNetFormElement.ReplaceWith(aspNetFormElement.Nodes()); } }
public object Execute(ParameterList parameters, FunctionContextContainer context) { try { var dynamicMethod = DynamicMethodHelper.GetDynamicMethod("<C1 function> " + _functionToWrap.CompositeName()); return dynamicMethod(() => _functionToWrap.Execute(parameters, context)); } catch (Exception ex) { if (_functionToWrap.ReturnType == typeof(XhtmlDocument)) { XElement errorBoxHtml; if (context.ProcessException(_functionToWrap.CompositeName(), ex, LogTitle, out errorBoxHtml)) { XhtmlDocument errorInfoDocument = new XhtmlDocument(); errorInfoDocument.Body.Add(errorBoxHtml); return errorInfoDocument; } } throw; } }
private static XhtmlDocument BuildDefaultDocument(IVisualFunction newFunction) { XElement htmlTable = new XElement(Namespaces.Xhtml + "table"); Type interfaceType = TypeManager.GetType(newFunction.TypeManagerName); DataTypeDescriptor typeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(interfaceType); foreach (DataFieldDescriptor dataField in typeDescriptor.Fields.OrderBy(f => f.Position)) { if (!typeDescriptor.KeyPropertyNames.Contains(dataField.Name) && dataField.FormRenderingProfile != null && !string.IsNullOrEmpty(dataField.FormRenderingProfile.Label)) { string fieldMarkup = string.Format("<data:fieldreference fieldname=\"{0}\" typemanagername=\"{1}\" xmlns:data=\"{2}\" />", dataField.Name, newFunction.TypeManagerName, Namespaces.DynamicData10); htmlTable.Add(new XElement(Namespaces.Xhtml + "tr", new XElement(Namespaces.Xhtml + "td", dataField.FormRenderingProfile.Label), new XElement(Namespaces.Xhtml + "td", XElement.Parse(fieldMarkup)))); } } XhtmlDocument defaultDocument = new XhtmlDocument(); defaultDocument.Body.Add(htmlTable); return defaultDocument; }
/// <exclude /> protected override void CreateChildControls() { if (InnerContent == null) { ProcessInternalControls(); } if (InnerContent != null) { var functionContextContainer = _functionContextContainer; if (functionContextContainer == null && this.NamingContainer is UserControlFunction) { var containerFunction = this.NamingContainer as UserControlFunction; functionContextContainer = containerFunction.FunctionContextContainer; } if (functionContextContainer == null) { functionContextContainer = PageRenderer.GetPageRenderFunctionContextContainer(); } var controlMapper = (IXElementToControlMapper) functionContextContainer.XEmbedableMapper; PageRenderer.ExecuteEmbeddedFunctions(InnerContent, functionContextContainer); var xhmlDocument = new XhtmlDocument(InnerContent); PageRenderer.NormalizeXhtmlDocument(xhmlDocument); PageRenderer.ResolveRelativePaths(xhmlDocument); if (PageRenderer.CurrentPage != null) { PageRenderer.ResolvePageFields(xhmlDocument, PageRenderer.CurrentPage); } NormalizeAspNetForms(xhmlDocument); AddNodesAsControls(xhmlDocument.Body.Nodes(), this, controlMapper); if (Page.Header != null) { MergeHeadSection(xhmlDocument, Page.Header, controlMapper); } } base.CreateChildControls(); }
/// <summary> /// Parses an xhtml fragment of into an XhtmlDocument. /// </summary> /// <param name="fragment"></param> /// <returns></returns> public static XhtmlDocument ParseXhtmlFragment(string fragment) { if (string.IsNullOrEmpty(fragment)) { return new XhtmlDocument(); } var nodes = new List<XNode>(); using (var stringReader = new StringReader(fragment)) { var xmlReaderSettings = new XmlReaderSettings { IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Parse, MaxCharactersFromEntities = 10000000, XmlResolver = null, ConformanceLevel = ConformanceLevel.Fragment // Allows multiple XNode-s }; var inputContext = FragmentContainsHtmlEntities(fragment) ? GetXhtmlFragmentParserContext() : null; using (var xmlReader = XmlReader.Create(stringReader, xmlReaderSettings, inputContext)) { xmlReader.MoveToContent(); while (!xmlReader.EOF) { XNode node = XNode.ReadFrom(xmlReader); nodes.Add(node); } } } if (nodes.Count == 1 && nodes[0] is XElement && (nodes[0] as XElement).Name.LocalName == "html") { return new XhtmlDocument(nodes[0] as XElement); } var document = new XhtmlDocument(); document.Body.Add(nodes); return document; }
public override bool TryConvert(object value, Type targetType, out object targetValue) { Verify.ArgumentNotNull(value, "value"); if (targetType == typeof(XhtmlDocument) && value is XElement) { XElement valueCasted = (XElement)value; targetValue = new XhtmlDocument(valueCasted); return true; } if (targetType == typeof(XElement) && value is XhtmlDocument) { XhtmlDocument valueCasted = (XhtmlDocument)value; targetValue = valueCasted.Root; return true; } if (targetType == typeof(XNode) && value is XhtmlDocument) { XhtmlDocument valueCasted = (XhtmlDocument)value; targetValue = valueCasted.Root; return true; } targetValue = null; return false; }
private void editPreviewActivity_ExecuteCode(object sender, EventArgs e) { Stopwatch functionCallingStopwatch = null; long millisecondsToken = 0; CultureInfo oldCurrentCulture = Thread.CurrentThread.CurrentCulture; CultureInfo oldCurrentUICulture = Thread.CurrentThread.CurrentUICulture; try { IXsltFunction xslt = this.GetBinding<IXsltFunction>("CurrentXslt"); string xslTemplate = this.GetBinding<string>("XslTemplate"); IFile persistemTemplateFile = IFileServices.TryGetFile<IXsltFile>(xslt.XslFilePath); if (persistemTemplateFile != null) { string persistemTemplate = persistemTemplateFile.ReadAllText(); if (this.GetBinding<int>("XslTemplateLastSaveHash") != persistemTemplate.GetHashCode()) { xslTemplate = persistemTemplate; ConsoleMessageQueueFacade.Enqueue(new LogEntryMessageQueueItem { Level = LogLevel.Fine, Message = "XSLT file on file system was used. It has been changed by another process.", Sender = this.GetType() }, this.GetCurrentConsoleId()); } } List<NamedFunctionCall> namedFunctions = this.GetBinding<IEnumerable<NamedFunctionCall>>("FunctionCalls").ToList(); // If preview is done multiple times in a row, with no postbacks an object reference to BaseFunctionRuntimeTreeNode may be held // If the function in the BaseFunctionRuntimeTreeNode have ben unloaded / reloaded, this preview will still run on the old instance // We force refresh by serializing / deserializing foreach (NamedFunctionCall namedFunction in namedFunctions) { namedFunction.FunctionCall = (BaseFunctionRuntimeTreeNode)FunctionFacade.BuildTree(namedFunction.FunctionCall.Serialize()); } List<ManagedParameterDefinition> parameterDefinitions = this.GetBinding<IEnumerable<ManagedParameterDefinition>>("Parameters").ToList(); Guid pageId = this.GetBinding<Guid>("PageId"); string dataScopeName = this.GetBinding<string>("PageDataScopeName"); string cultureName = this.GetBinding<string>("ActiveCultureName"); CultureInfo cultureInfo = null; if (cultureName != null) { cultureInfo = CultureInfo.CreateSpecificCulture(cultureName); } IPage page; TransformationInputs transformationInput; using (new DataScope(DataScopeIdentifier.Deserialize(dataScopeName), cultureInfo)) { Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo; page = DataFacade.GetData<IPage>(f => f.Id == pageId).FirstOrDefault(); if (page != null) { PageRenderer.CurrentPage = page; } functionCallingStopwatch = Stopwatch.StartNew(); transformationInput = RenderHelper.BuildInputDocument(namedFunctions, parameterDefinitions, true); functionCallingStopwatch.Stop(); Thread.CurrentThread.CurrentCulture = oldCurrentCulture; Thread.CurrentThread.CurrentUICulture = oldCurrentUICulture; } string output = ""; string error = ""; try { Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo; var styleSheet = XElement.Parse(xslTemplate); XsltBasedFunctionProvider.ResolveImportIncludePaths(styleSheet); LocalizationParser.Parse(styleSheet); XDocument transformationResult = new XDocument(); using (XmlWriter writer = new LimitedDepthXmlWriter(transformationResult.CreateWriter())) { XslCompiledTransform xslTransformer = new XslCompiledTransform(); xslTransformer.Load(styleSheet.CreateReader(), XsltSettings.TrustedXslt, new XmlUrlResolver()); XsltArgumentList transformArgs = new XsltArgumentList(); XslExtensionsManager.Register(transformArgs); if (transformationInput.ExtensionDefinitions != null) { foreach (IXsltExtensionDefinition extensionDef in transformationInput.ExtensionDefinitions) { transformArgs.AddExtensionObject(extensionDef.ExtensionNamespace.ToString(), extensionDef.EntensionObjectAsObject); } } Exception exception = null; HttpContext httpContext = HttpContext.Current; Thread thread = new Thread(delegate() { Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo; Stopwatch transformationStopwatch = Stopwatch.StartNew(); try { using (ThreadDataManager.Initialize()) using (new DataScope(DataScopeIdentifier.Deserialize(dataScopeName), cultureInfo)) { HttpContext.Current = httpContext; var reader = transformationInput.InputDocument.CreateReader(); xslTransformer.Transform(reader, transformArgs, writer); } } catch (ThreadAbortException ex) { exception = ex; Thread.ResetAbort(); } catch (Exception ex) { exception = ex; } transformationStopwatch.Stop(); millisecondsToken = transformationStopwatch.ElapsedMilliseconds; }); thread.Start(); bool res = thread.Join(1000); // sadly, this needs to be low enough to prevent StackOverflowException from fireing. if (res == false) { if (thread.ThreadState == System.Threading.ThreadState.Running) { thread.Abort(); } throw new XslLoadException("Transformation took more than 1000 milliseconds to complete. This could be due to a never ending recursive call. Execution aborted to prevent fatal StackOverflowException."); } if (exception != null) { throw exception; } } if (xslt.OutputXmlSubType == "XHTML") { XhtmlDocument xhtmlDocument = new XhtmlDocument(transformationResult); output = xhtmlDocument.Root.ToString(); } else { output = transformationResult.Root.ToString(); } } catch (Exception ex) { output = "<error/>"; error = string.Format("{0}\n{1}", ex.GetType().Name, ex.Message); Exception inner = ex.InnerException; string indent = ""; while (inner != null) { indent = indent + " - "; error = error + "\n" + indent + inner.Message; inner = inner.InnerException; } } finally { Thread.CurrentThread.CurrentCulture = oldCurrentCulture; Thread.CurrentThread.CurrentUICulture = oldCurrentUICulture; } Page currentPage = HttpContext.Current.Handler as Page; if (currentPage == null) throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page"); UserControl inOutControl = (UserControl)currentPage.LoadControl(UrlUtils.ResolveAdminUrl("controls/Misc/MarkupInOutView.ascx")); inOutControl.Attributes.Add("in", transformationInput.InputDocument.ToString()); inOutControl.Attributes.Add("out", output); inOutControl.Attributes.Add("error", error); inOutControl.Attributes.Add("statusmessage", string.Format("Execution times: Total {0} ms. Functions: {1} ms. XSLT: {2} ms.", millisecondsToken + functionCallingStopwatch.ElapsedMilliseconds, functionCallingStopwatch.ElapsedMilliseconds, millisecondsToken)); FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId); var webRenderService = serviceContainer.GetService<IFormFlowWebRenderingService>(); webRenderService.SetNewPageOutput(inOutControl); } catch (Exception ex) { FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId); Control errOutput = new LiteralControl("<pre>" + ex.ToString() + "</pre>"); var webRenderService = serviceContainer.GetService<IFormFlowWebRenderingService>(); webRenderService.SetNewPageOutput(errOutput); } }