0

We have multiple RSS feeds in Tridion-based .NET websites. The RSS feeds need to be rendered as utf-8 (for content syndications). However, currently, they are rendered as urf-16 in the PROD environment.

Sample URLs: https://www.apa.org/news/apa/rss.xml https://www.apaservices.org/practice/clinic/covid-19-resources-rss.xml

If you view the page source in the browser, you will see the encoding is utf-16.

Most feeds are rendered based on broker query results. In some cases, the feed items are managed via a component in CMS. In all environments, the templates/TBBs and web applications are identical except for environment variables such as DB connection strings in web.config. The "preview" (stage) and "www" (live) sites are supported by the same CMS in PROD.

Currently, all feeds rendered via DXA web applications in DEV, QA and Preview show utf-8. But they all show utf-16 in the live sites.

FYI, the feeds in PROD also show urf-8 when debugging in Visual Studio using the localhost. We have Tridion Sites version 9.0 and DXA 2.1.

Update from Ahmad:

To make things clear. Let me show you sample code similar to our RSS feeds implementation:

public SyndicationFeed Feed { get; set; }
public override void ExecuteResult(ControllerContext context)
{
    context.HttpContext.Response.ContentType = "application/xml";
    context.HttpContext.Response.ContentEncoding = Encoding.UTF8;
    var rssFormatter = Feed.GetRss20Formatter();

    rssFormatter.SerializeExtensionsAsAtom = false;

    var xmlDoc = new XmlDocument();

    using (var writer = XmlWriter.Create(xmlDoc.CreateNavigator().AppendChild()))
    {
        rssFormatter.WriteTo(writer);
    }

    //
    // A few lines of code for some nodes custom implementation 
    //

    using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
    {
        xmlDoc.WriteTo(writer);
    }
}

Above code is written in a class (say RssActionResult) that inheriting from ActionResult class and being used in application PageController.

2
  • Welcome to Tridionstackexchange, It's purely .NET related questions about how RSS Feed XML should be handled in server and client. enable logs to process and save the XML in the server before a response to see the generated RSS feed generated as expected in utf-8. check the response content-type has correct content-type and encoding.
    – Velmurugan
    Commented Oct 7, 2020 at 14:56
  • How is RSS generation done in your implementation? DXA has built-in RSS capabilities, but your example URLs hint at a custom implementation. Commented Oct 7, 2020 at 17:59

1 Answer 1

0

I'm Ahmad from Merry's web development team. To make things clear. Let me show you sample code similar to our RSS feeds implementation:

    public SyndicationFeed Feed { get; set; }
    public override void ExecuteResult(ControllerContext context)
    {
        context.HttpContext.Response.ContentType = "application/xml";
        context.HttpContext.Response.ContentEncoding = Encoding.UTF8;
        var rssFormatter = Feed.GetRss20Formatter();

        rssFormatter.SerializeExtensionsAsAtom = false;

        var xmlDoc = new XmlDocument();

        using (var writer = XmlWriter.Create(xmlDoc.CreateNavigator().AppendChild()))
        {
            rssFormatter.WriteTo(writer);
        }

        //
        // A few lines of code for some nodes custom implementation 
        //

        using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
        {
            xmlDoc.WriteTo(writer);
        }
    }
    

Above code is written in a class (say RssActionResult) that inheriting from ActionResult class and being used in application PageController.

5
  • 1
    This is not an answer.Please update the question with this (useful) additional info. Commented Oct 9, 2020 at 10:25
  • 1
    BTW: this makes clear that the RSS generation is indeed a custom implementation, making this a general .NET question (as Velmurugan also commented). Commented Oct 9, 2020 at 10:27
  • Thank you @RickPannekoek, actually I couldn't add a comment to the original question (must have 50 reputations..). I have updated the question with my stuff (not yet approved). We really tried hard to solve this, as Merry said all environments are working fine. Only the PROD is (weirdly) rendered as utf-16, using same code and almost same everything. Commented Oct 9, 2020 at 12:32
  • Try explicitly setting the encoding on the XmlWriter: docs.microsoft.com/en-us/dotnet/api/… Commented Oct 12, 2020 at 5:55
  • 1
    Although it remains as a mystery that the rss feeds are rendered as utf-16 in PROD while working as desired utf-8 in DEV/QA/Preview, setting the encoding explicitly appears resolving the issue. Thank you all for the help! Commented Oct 15, 2020 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.