Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Dynamic Content and ViewUrl in MVC?


I'm trying to make an XForm dynamic content in EPiServer 7 MVC but I can't really get it to work.

At the moment I've created a class which looks like this:

    [DynamicContentPlugIn(DisplayName = "XForms", ViewUrl = "~/Views/Shared/DynamicContent/XFormView.cshtml")]
    public class XForms : DynamicContentBase, IDynamicContentView
        public XForms()
            Properties = new PropertyDataCollection {{"XFormControl", new PropertyXForm()}};

        public virtual void Render(TextWriter writer)
            writer.Write("<div>Hello world</div>");

With this i was hoping that the file specified in the ViewUrl property would be rendered but all that will render is the "Hello world" in the Render method. Can someone give me some guidance on how I can load  this view or give tips on how to load an xform control in the render method?

Oct 08, 2013 14:28

What happens if you remove the Render method?

Oct 08, 2013 16:05

That's not possible since I implement IDynamicContentView

Oct 08, 2013 16:13

What happens if you remove IDynamicContentView? I did something similar a while a go and I couldn't have both the render method and the ViewUrl as one canceled out the other.

Oct 08, 2013 16:14

Ah yes you're righ! When i removed that interface i was able to render the view. Now just to figure out how to render the xform object from the model which is a dynamic content :)

Oct 08, 2013 16:23

any luck with this one? 

wheni delete IDynamicContentView it complains it not compatible with MVC

But when it is included it wont go to my view ".cshtml" and onyl runs Render

Apr 14, 2016 16:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.