Episerver Forms on non-MVC Razor project


I know that docs here (https://docs.developers.optimizely.com/content-cloud/v1.2.0-forms/docs) says,
that "Optimizely Forms is only supported by MVC-based websites and HTML5-compliant browsers.",

but still is there any way to make Forms work on non-MVC razor projects on FE side?

Edited, Oct 03, 2022 12:24

Could you possibly use the Conetent Delivery API or Content Definitions API (https://world.optimizely.com/documentation/class-libraries/rest-apis/content-definitions-api/) to retrieve Forms and their Fields and then build the frontend in whatever framework you use. You could also use the Forms Service API to retrieve data. (https://docs.developers.optimizely.com/content-cloud/v1.2.0-forms/docs/using-forms-serviceapi

Oct 03, 2022 13:11
klappo - Oct 03, 2022 13:20
so, it's not really possible to use existing epi code to render form and inject it into any other page?

@Klappo is your solution headless or are you trying to use a completely different server side rendering engine to the CMS?

If you're going to want to embed the form with an iFrame along those lines, you could potentially look a single MVC Razor page which is designed to hold a single form container block so that you get all of the forms handling out of the box.  But this does feel a little hacky.

You could follow Minesh's solution to build the form and then submit the response to the following url as form data.  This is based on the EPiServer.Forms.Controllers.DataSubmitController  


I would add that I've not needed to do any of the above, but it would be interesting to try.

Oct 03, 2022 17:00

Have a look at this blog post, it's old but (so are webforms and) it might help...


Oct 03, 2022 19:14

Thanks everybody for the help!

In the end I was able to implement that. I had to copy Forms cshtml view, override default Forms ViewComponent
and fix null ref exceptions (viewcomponent supposes that it is rendered on some page). 

I had issues wth the order of view component parts rendering, but, again, I fixed that as well.

Then I was able to load the form by its id and submit some data to epi.

Edited, Oct 18, 2022 7:08
* 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.