Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mik 7 posts 79 karma points
    Mar 25, 2019 @ 13:22
    Mik
    1

    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?

  • Arotek 1 post 71 karma points
    Mar 25, 2019 @ 13:41
    Arotek
    0

    So in essense I am splitting up GETs and POSTs between two controllers.

    Yep! That's the idea. Split them into two separate controllers :)

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Mar 26, 2019 @ 09:48
    Alex Skrypnyk
    0

    Hi Mik

    You are right, for handling POST and GET requests use SurfaceController, also there is UmbracoApiController btw.

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft