How do you modify the meta tags rendered by `ltlTags`?

Bryan Drenner asked on September 15, 2014 23:33

I'm working on a new master page, and I noticed some unwelcome meta tags being inserted into the ltlTags literal:

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" /> 
<meta http-equiv="content-style-type" content="text/css" /> 
<meta http-equiv="content-script-type" content="text/javascript" />

Does the CMS provide a place to edit (and remove) these?

I've only managed to find hacks so far, like manually parsing ltlTags.Text on prerender.

Correct Answer

Brenden Kehren answered on September 16, 2014 18:16

Nice.

I've had an in-depth discussion in a LinkedIn closed group with several large Kentico partners and all of them agreed, even with your similar concerns, there is no reason to use straight ASPX mode. Some have simply because the client requested it but then ended up going back. Some find a mix of ASPX and Portal, which works but in my opinion, is a temporary solution until you find out how to do what you're doing in ASPX in Portal mode.

Re: version control and editing in VS, think we've already talked about these things in previous posts. ;) Kentico provides these developer tools (most since v6) to do all of the things you have concerns with, no matter if you're a team of 1 developer or a team of 10 developers working on the same site or instance.

It's never fun to inherit something in a not-so-good state...

So the short answer is to follow what you have found as hacks for the tags in the prerender event.

2 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on September 16, 2014 13:36

Hey Bryan, assuming v8, I don't have that problem on any instance I've implemented. I have to manually add the charset in most cases. You might try testing when you are logged out completely OR check your master page header section.

0 votesVote for this answer Mark as a Correct answer

Ondrej Sevcik answered on September 16, 2014 16:39

Hi, if you have XHTML website these tags are automatically added to your markup. As far as I know there is no easy way how to get rid of these meta tags.

0 votesVote for this answer Mark as a Correct answer

Chris Tusciuk answered on September 16, 2014 17:04

Ondrej, this master page / page template uses HTML5. Is there a way to instruct Kentico that it's an HTML5 website as opposed to an XHTML website?

Brenden, I created a simplified master page to demonstrate my problem. Below is the .master file, the page template's .aspx file, and then what is actually rendered to a public/anonymous user. The code-behind is empty aside from the boilerplate.

Here's the .master file:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="DemoMasterPage.Master.cs" Inherits="CMSApp.CMSTemplates.DemoMasterPage" %>
<!DOCTYPE html>
<html>
    <head id="Head1" runat="server">
        <title id="Title1" runat="server"></title>
        <!-- <ltlTags> -->
            <asp:Literal ID="ltlTags" EnableViewState="false" runat="server" />
        <!-- </ltlTags> -->
    </head>
    <body class="<%=BodyClass%>" <%=BodyParameters%>>
        <form id="form1" runat="server">
            <asp:PlaceHolder ID="plcManagers" runat="server">
                <ajaxToolkit:ToolkitScriptManager ID="manScript" EnableViewState="false" ScriptMode="Release" runat="server" />
                <cms:CMSPortalManager ID="CMSPortalManager1" EnableViewState="false" runat="server" />
            </asp:PlaceHolder>
             <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </form>
    </body>
</html>

Here's the .aspx page template:

<%@ Page Title="" Language="C#" MasterPageFile="~/CMSTemplates/DemoMasterPage.Master" AutoEventWireup="true" CodeBehind="DemoPageTemplate.aspx.cs" Inherits="CMSApp.CMSTemplates.DemoPageTemplate" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <p>Yo</p>
    <cms:CMSEditableRegion ID="MainContentEditableRegion" runat="server" DialogHeight="400" RegionType="HtmlEditor" RegionTitle="Main Content" />
</asp:Content>

And the actual, rendered HTML:

<!DOCTYPE html>
<html>
<head id="ctl00_Head1">
    <title>
        Our Site Title - Experiment
    </title>
    <!-- <ltlTags> -->
        <meta name="description" content="Our site description" />
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta http-equiv="pragma" content="no-cache" />
        <meta http-equiv="content-style-type" content="text/css" />
        <meta http-equiv="content-script-type" content="text/javascript" />
        <link href="/CMSPages/GetResource.ashx?stylesheetname=OurStylesheetName" type="text/css" rel="stylesheet" />
    <!-- </ltlTags> -->
</head>
<body class="LTR Safari Chrome Safari37 Chrome37 ENUS ContentBody">
    <form method="post" action="/Experiment.aspx" id="aspnetForm">
        <div class="aspNetHidden">
            <input type="hidden" name="ctl00_manScript_HiddenField" id="ctl00_manScript_HiddenField" value="" />
            <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
            <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
            <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzkwOTkxMzYxDxYCHhNWYWxpZGF0ZVJlcXVlc3RNb2RlAgEWAmYPZBYEZg9kFgQCBA8WAh4EaHJlZgVaL0NNU1BhZ2VzL0dldFJlc291cmNlLmFzaHg/c3R5bGVzaGVldGZpbGU9L0FwcF9UaGVtZXMvTmV3NDIuTmV3VmljdG9yeS9kaWFsb2dQYWdlU3R5bGUuY3NzZAIFDxYCHwEFUC9DTVNQYWdlcy9HZXRSZXNvdXJjZS5hc2h4P3N0eWxlc2hlZXRmaWxlPS9BcHBfVGhlbWVzL05ldzQyLk5ld1ZpY3Rvcnkvc3R5bGUuY3NzZAIBDxYCHgZhY3Rpb24FEi9FeHBlcmltZW50LTIuYXNweGRkWNzrAIqAQhGN+utGjs7w7z2N4DZqgBpQECNkilwy0eA=" />
        </div>

        <script type="text/javascript">
            //<![CDATA[
            var theForm = document.forms['aspnetForm'];
            if (!theForm) {
                theForm = document.aspnetForm;
            }
            function __doPostBack(eventTarget, eventArgument) {
                if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
                    theForm.__EVENTTARGET.value = eventTarget;
                    theForm.__EVENTARGUMENT.value = eventArgument;
                    theForm.submit();
                }
            }
            //]]>
        </script>

        <script src="/WebResource.axd?d=hrfs6WP0NHW3AiHRXbQJyGZU2bwz6nJetf2wwaqGQwclOyxdYZAp4SIr8uXJfUW9nEgtnTCDQBh5y7tCslCK1wI7QXZNw0GDrZ7gVWk60HU1&amp;t=635200830466652144" type="text/javascript"></script>

        <input type="hidden" name="lng" id="lng" value="en-US" />
        <script type="text/javascript">
            //<![CDATA[

            function PM_Postback(param) { if (window.top.HideScreenLockWarningAndSync) { window.top.HideScreenLockWarningAndSync(1080); } if (window.CMSContentManager) { CMSContentManager.allowSubmit = true; }; __doPostBack('ctl00$CMSPortalManager1$am', param); }
            function PM_Callback(param, callback, ctx) { if (window.top.HideScreenLockWarningAndSync) { window.top.HideScreenLockWarningAndSync(1080); } if (window.CMSContentManager) { CMSContentManager.storeContentChangedStatus(); }; WebForm_DoCallback('ctl00$CMSPortalManager1$am', param, callback, ctx, null, true); }
            //]]>
        </script>
        <script src="/ScriptResource.axd?d=oDQsX_8uPIFwBmvp0DvFzvsybW20-DiXIPBCJW95W2Kupq6FRo0PNZ0WBh8pQrnUDFD5P8P8qLXTtxV483rwicvVdHJOudNIEV-HrtLb8Hs2MQInBi1lYlQuqdkCug0a0&amp;t=7c776dc1" type="text/javascript"></script>
        <script src="/ScriptResource.axd?d=vINF2zKqmPYdQwoWkDoKl9DdgrcW2FR7UIr_72054hpsbKQc28bDdR15-u8A82bia6FHvUHh0LaFJ7aMO9WFIWXkVXlioi4L1qge3hyI6-n7PKmcB16-NYLuGu4lYcRT0uKxC6ZrQApXqAXF9CYHlQ2&amp;t=7c776dc1" type="text/javascript"></script>
        <script type="text/javascript">
            //<![CDATA[

            var CMS = CMS || {};
            CMS.Application = {
                "isDialog": false,
                "applicationUrl": "/",
                "isRTL": "false",
                "imagesUrl": "/CMSPages/GetResource.ashx?image=%5bImages.zip%5d%2f"
            };

            //]]>
        </script>
        <script type="text/javascript">
            //<![CDATA[
            Sys.WebForms.PageRequestManager._initialize('ctl00$manScript', 'aspnetForm', ['tctl00$ctxM', ''], [], [], 90, 'ctl00');
            //]]>
        </script>
        <div id="ctl00_ctxM">

        </div>

        <p>Yo</p>

        <script type="text/javascript">
            //<![CDATA[
            (function () { var fn = function () { $get("ctl00_manScript_HiddenField").value = ''; Sys.Application.remove_init(fn); }; Sys.Application.add_init(fn); })();//]]>
        </script>

        <script type="text/javascript">
            //<![CDATA[
            if (typeof (Sys.Browser.WebKit) == 'undefined') {
                Sys.Browser.WebKit = {};
            }
            if (navigator.userAgent.indexOf('WebKit/') > -1) {
                Sys.Browser.agent = Sys.Browser.WebKit;
                Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
                Sys.Browser.name = 'WebKit';
            }
            //]]>
        </script>
        <script type="text/javascript">
            //<![CDATA[

            WebForm_InitCallback();//]]>
        </script>
    </form>
</body>
</html>
0 votesVote for this answer Mark as a Correct answer

Bryan Drenner answered on September 16, 2014 17:07

Oops. That last post was me, btw. I occasionally log into client.kentico.com as Robert to grab a license key, and I forget that it remembers that authentication for devnet.kentico.com.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 16, 2014 17:38

I've looked at least a dozen sites I'm working on or have worked on, some using HTML5 and some not, 1 in v6, some in v7 and some in v8 and 2 in ASPX mode vs. Portal and the only consistency I've found is the 2 developed in ASPX mode, had the code you mentioned. It had nothing to do with HTML5 or not.

Any reason you're using ASPX mode over Portal or what this simply for demonstration purposes?

0 votesVote for this answer Mark as a Correct answer

Ondrej Sevcik answered on September 16, 2014 17:53

It's a little bit complicated. If you are using ASPX templates than those meta tags are always appended. Portal engine with HTML5 doctype should be the only combination where those meta tags aren't appended.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 16, 2014 18:05

Ahh yes, I stand corrected, I have one site not HTML5 on Portal, I checked and it has those tags in there. The others I checked were all HTML5.

So question remains, any particular reason why ASPX over Portal?

0 votesVote for this answer Mark as a Correct answer

Bryan Drenner answered on September 16, 2014 18:08

I use ASPX mode for several reasons, which I'm willing to reevaluate.

  • I can edit the markup in Visual Studio. Maybe this is now irrelevant since Kentico can store virtual objects in the file system.
  • I can keep the markup under version control. This is also probably remedied by storing virtual objects in the file system.
  • The product was given to me like this when I started working here.
  • Our sites rely on a peculiar API for authentication and ecommerce features, and this API has an impedance mismatch with those features built into ASP.NET and Kentico, therefore requiring a lot of custom code. I now realize I probably could (and should) divvy this responsibility to custom controls and application event handlers. However, this would require significant refactoring.
  • I feel like I have more control over things, though that feeling is waning.
0 votesVote for this answer Mark as a Correct answer

Bryan Drenner answered on September 16, 2014 18:19

Thanks, Brenden. I think I'll give pure Portal mode a shot and see how it works out.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 16, 2014 22:01

Look me up Bryan if you need a hand, I'm pretty easy to find...

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.