I have a custom routed RenderMvcController that lists out rows of a custom database table.
If I want a form that creates a new record, it seems that because of how the RenderMvController is wired up to Umbraco.Web.Models.RenderModel which always wants an IPublishedContent instance, to use just a simple view model/DTO with validation attributes, etc seems complicated.
The recommended approach instead seems to use a SurfaceController instead. So in essense I am splitting up GETs and POSTs between two controllers. (I know Surface controllers can render child actions too)
Is this the correct way of doing this when using a custom controller, or am I missing something?
Post requests to RenderMvcController?
I have a custom routed RenderMvcController that lists out rows of a custom database table.
If I want a form that creates a new record, it seems that because of how the RenderMvController is wired up to
Umbraco.Web.Models.RenderModel
which always wants an IPublishedContent instance, to use just a simple view model/DTO with validation attributes, etc seems complicated.The recommended approach instead seems to use a
SurfaceController
instead. So in essense I am splitting up GETs and POSTs between two controllers. (I know Surface controllers can render child actions too)Is this the correct way of doing this when using a custom controller, or am I missing something?
Yep! That's the idea. Split them into two separate controllers :)
Hi Mik
You are right, for handling POST and GET requests use
SurfaceController
, also there is UmbracoApiController btw.Thanks,
Alex
is working on a reply...