Enhancing Embedded Content in Sitefinity with a Custom HTML Sanitizer
Sitefinity’s default HTML sanitization can unintentionally strip key attributes from embedded media, limiting video functionality and user experience. By customizing an open-source sanitizer, Visus enabled full support for embedded content like YouTube and Vimeo—restoring expected behavior across all devices.
Jul 14, 2025

Rich content experiences often depend on seamless integration with third-party platforms like YouTube and Vimeo. However, when a client began embedding external media into Sitefinity's .NET Core Renderer using Content Blocks, unexpected limitations emerged. Essential functionality, such as fullscreen playback and custom video controls, was disabled. Sitefinity's default sanitization process automatically modifies or strips key attributes from iframe elements, resulting in a diminished user experience.

To restore full functionality, a custom HTML sanitization solution was developed.

The team extended the widely used Ganss.Xss.HtmlSanitizer library to create a tailored sanitizer capable of handling Sitefinity's specific requirements. The custom implementation scanned the inner HTML of Content Blocks and identified iframe tags. It then appended missing attributes critical for embedded content performance—attributes that Sitefinity's default processing either altered or removed.

This sanitizer was registered as a singleton service within the .NET Core Renderer's Program.cs file. With this approach in place, any content rendered through widgets or rich-text fields was automatically processed to ensure the inclusion of necessary iframe attributes. As a result, embedded videos and interactive resources are now rendered properly, preserving the expected user interactions across browsers and devices.

This project reinforced two important development principles. First, a deep understanding of default platform behaviors is essential when diagnosing unexpected issues. Second, leveraging and customizing reliable open-source libraries—rather than building from scratch—can accelerate delivery while meeting unique requirements.

By developing a targeted solution within Sitefinity's architecture, the team ensured the client could confidently embed rich media content without compromising usability or design standards.

Begin Your Success Story

By using this website, you agree to our use of cookies. We use cookies to provide you with a great experience and to help our website run effectively. For more, see our Privacy Policy.