SaaS CMS has officially launched! Learn more now.

Creating custom form submit controller


Tried implementing the example for having the custom form submit controller however doing so I get an error stating it cannot find a default controller for form submissions. How do I override and set which controller to use? 

Error Message:

Additional information: No default Instance is registered and cannot be automatically determined for type 'EPiServer.Forms.Controllers.IDataSubmitController'


Apr 20, 2016 16:54

Sounds like you are missing a line in structuremap config?

Apr 21, 2016 15:47

Sounds like something I would be missing. I have not found any sort of documentation of what and where needs changed besides adding that file. 

Any idea what I need to do exactly?

Apr 21, 2016 16:00

Tried the attribute?


and then add a line in

to map the IDataSubmitController to your implementation.

Edited, Apr 21, 2016 16:11

(Was already using this)

    public class DemoSubmitFormController : DataSubmitController
        public ActionResult Index()
            return View();


I copied the class from your example and modified Initialize to the following: 

public void Initialize(InitializationEngine context)
            _serviceConfigurationContext.Container.Configure(c =>
                c.For<IDataSubmitController>().Use(new DemoSubmitFormController()); 

It still throws the same exception. 

Apr 21, 2016 16:51


Sorry for the missing information. In the beginning, we intended to use IDataSubmitController and StructureMap for resolving the CoreController for Forms to work. But later on, we decide to use normal ASP.NET MVC controller because it would be easier. (We might change, so the DI solution like yours would work). So last time I check (with AlloyMVC as a test website) this is true for Forms 2.0:

You can use your own controller.

  • Make a controller. GetFormInitScript() and Submit() are most important methods.
  • map the route in Global.asax RouteTable.Routes.MapRoute("DemoSubmitFormController", "demo/{controller}/{action}", new { controller = "demosubmitform" , action = "Index" });
  • Modify Forms.config (inside the modules/_protected folder)
<episerverforms ...




You can reconfigure the coreController to point to any ASP.NET MVC controller.

I will update the Demo project and write an article for this. Thank you.


Edited, May 05, 2016 13:54

Hi @Lockevn - I've successfully routed and configured forms to use a custom controller which inherits DataSubmitController.  I want to just use the base GetFormInitScript and only override the Submit action.  When the base GetFormInitScript action is called I'm getting an error (Unable to find a module by assembly '[my assembly detail]' Parameter name: moduleAssembly).  Is there some additional config to allow this to work? Thanks.


May 16, 2016 10:56

Hi Neil,

The GetFormInitScript() utilizes Paths.ToResource(GetType(), "Views/FormContainerInitScript.ascx") to take the ascx template, then render the JavaScript from that template.
By default, the template is in wwwroot\modules\_protected\EPiServer.Forms\Views/FormContainerInitScript.ascx
Because your  custom controller is not in a correct "Episerver module", the Paths.ToResource() fails.

Let's say, you write your custom Controller in AlloyMVC (which is an correct "Episerver module"), DataSubmitController.GetFormInitScript() will take the view from wwwroot/Views/FormContainerInitScript.ascx

There is no more configuration.

We will change DataSubmitController.GetFormInitScript() to take view from exactly in EPiServer.Forms module (use typeof(DataSubmitController) instead of using just GetType()) . But at the moment, you have to override it totally. Sorry for this.

May 16, 2016 11:06

Thanks Lockevn, I reflected it and have it working using typeof.

May 16, 2016 12:33

We will change DataSubmitController.GetFormInitScript() to take view from exactly in EPiServer.Forms module (use typeof(DataSubmitController) instead of using just GetType()) . But at the moment, you have to override it totally. Sorry for this.

AFORM-665 is fixed and closed in Forms 3.0

Jun 13, 2016 8:43
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.