Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide
GitHubNuGetDev CommunityOptimizely AcademySubmit a ticket

Optimizely developer documentation

How can we help you?

Try our conversational search powered by Generative AI!

AI OnAI Off

Create MVC component

Describes how to create a component in the Optimizely Content Management System (CMS) user interface.

The Optimizely Content Management System (CMS) extension of the IFrameComponent has the following additional parameters:

  • UrlFromUtil – Optional. The URL to the source, relative to the Utils folder. Used instead of Url property.
  • UrlFromUi – Optional. The URL to the source, relative to the UI folder. Used instead of Url property.

First, you need to add a controller. The controller has to be annotated with an IframeComponent attribute.

[IFrameComponent(Url = "/helloworld", Title = "Hello World Component", Categories = "content")] public class HelloWorldController: Controller { public ActionResult Index() { return View(); } }

Then add a Index.cshtml view to the Views/HelloWorld directory:

@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>HelloWorld</title> </head> <body> <div> <div>Hello World</div> </div> </body> </html>

Did this page help you?