1

I am trying to render an Ascx page from an MVC View Rendering in Sitecore. For example, in old Web Forms / Ascx to put placeholders you'd use

<sc:Placeholder runat="server" key="placeholder-key" />

the Mvc equivalent is

@Html.Sitecore().Placeholder("placeholder-key")

but I want to do the MVC equivalent of

<sc:Sublayout runat="server" Path="widget.ascx" DataSource="Content" Cacheable="True" VaryByData="True" />

Or if I can't, is there a way to render the in my MVC cshtml layuout.

The reason is because I am trying to convert an old .ascx web page to a cshtml one. Any help please?

4

It's definitely not as simple as Vlad makes it out to be.

Officially, Sitecore does not support this. You can mix and match MVC and WebForms in the same project, but only on a page-by-page basis. So either the page executes as Webforms (with Webforms components) or as MVC with MVC components.

There's been a few attempts to wedge around this, but I would not recommend going down an unsupported route. One example here:

https://horizontalintegration.blog/2015/09/15/mixing-sublayout-with-rendering-webforms-with-mvc-request/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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