Webforms project integration with composite C1

We developed the ASP.Net Webforms application, a kind of online store. Some of the pages contain only editorial content, news, articles, etc. This data is coming from the database right now and is difficult to edit for content authors.

My boss wants me to check if we can use Composite C1 as a CMS and integrate it with Project.

I watched it now and played with it for several days, but I'm still not sure if this is a good idea and how exactly I will integrate the two systems.

  • The navigation menus and some other permanent parts of the website are retrieved from the database and should also be displayed on the editorial pages.
  • We use friendly SEO (Routing) URLs and the URLs should remain the same.

How difficult is it to combine the two projects? Should I abandon the old ASP.Net Website project and put all my sites in the Composite project? Or it will be possible to work as side by side, even if they have common navigation menus, etc.

Will there be a routing problem?

Has anyone done such a merger before? Any experience would be a big help.

+4
source share
1 answer

C1 uses Webforms to host its content, so you canโ€™t do anything what you are doing now in your webforms project. You can use Webforms Masterpages as templates for your content, and routing is fully supported either by adding as many custom routes as possible, or simply redefining the default page c1 route. Or rely on PathInfo Api , where the unsurpassed parts of the URL will be available for use on the page that matches the longest part of the URL. You can also use Razor (.cshtml) in C1 if you like this new Microsoft syntax.

You can also rotate things and choose to render content from C1 on your existing pages. This code shows how a standard WebForm.aspx page can be used to render content from a specific page in C1

public class BaseContentTeaserPage : Page { private Guid _pageId; protected PlaceHolder plc; protected override void OnPreInit(EventArgs e) { _pageId = Guid.Parse(Request.QueryString["pageId"]); using (new DataScope(PublicationScope.Published, new CultureInfo("en-GB"))) { using (var data = new DataConnection()) { PageRenderer.CurrentPage = data.Get<IPage>().Single(p => p.Id == _pageId); var urlData = new PageUrlData(PageRenderer.CurrentPage); urlData.PathInfo = Request.QueryString["pathInfo"]; Context.Items["C1_PageUrl"] = urlData; } } base.OnPreInit(e); } protected override void OnLoad(EventArgs e) { using (new DataScope(PublicationScope.Published, new CultureInfo("en-GB"))) { var content = DataFacade.GetData<IPagePlaceholderContent>().Single(p => p.PageId == _pageId); var helper = new PageRendererHelper(); var mapper = (IXElementToControlMapper)helper.FunctionContext.XEmbedableMapper; var doc = helper.RenderDocument(content); var body = PageRendererHelper.GetDocumentPart(doc, "body"); addNodesAsControls(body.Nodes(), plc, mapper); if (Page.Header != null) { var head = PageRendererHelper.GetDocumentPart(doc, "head"); if (head != null) { addNodesAsControls(head.Nodes(), Page.Header, mapper); } } } base.OnLoad(e); } private static void addNodesAsControls(IEnumerable<XNode> nodes, Control parent, IXElementToControlMapper mapper) { foreach (var node in nodes) { var c = node.AsAspNetControl(mapper); parent.Controls.Add(c); } } protected override void Render(HtmlTextWriter writer) { var markupBuilder = new StringBuilder(); using (var sw = new StringWriter(markupBuilder)) { base.Render(new HtmlTextWriter(sw)); } string xhtml = markupBuilder.ToString(); using (Profiler.Measure("Changing 'internal' page urls to 'public'")) { xhtml = PageUrlHelper.ChangeRenderingPageUrlsToPublic(xhtml); } using (Profiler.Measure("Changing 'internal' media urls to 'public'")) { xhtml = MediaUrlHelper.ChangeInternalMediaUrlsToPublic(xhtml); } writer.Write(xhtml); } } 
+5
source

All Articles