Copied to clipboard

Flag this post as spam?

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

  • Olivia Philomena Moser 7 posts 87 karma points
    17 days ago
    Olivia Philomena Moser

    Can I create all CRUD Operations in a Surface Controller?

    So I was wondering if it is possible to use a Surface Controller for all crud operations (Umbraco V10). I know that I can create a Post method, but is it possible to add a Delete or Patch method? I tried to add a method like this:

    public class DeleteController : SurfaceController {
        public IActionResult Delete()

    but I only receive an 405 error telling me that the method is not allowed. If I change the [HttpDelet] to [HttpPost] the method works, but I think that is semantically not correct.

    And am I correct in saying that it is not common to have multiple methods in one Surface Controller? So I would have to create a Controller for each method.

  • Alex Skrypnyk 6120 posts 23747 karma points MVP 7x admin c-trib
    14 days ago
    Alex Skrypnyk

    Hi Olivia

    Can you try using api controllers ?

    SurfaceController are more like for interact with the front-end rendering of an Umbraco page. They can be used for rendering MVC child actions and for handling form data submissions. Surface controllers are auto-routed, meaning that you don't have to add/create your own routes for these controllers to work - From docs



  • Olivia Philomena Moser 7 posts 87 karma points
    1 day ago
    Olivia Philomena Moser

    Hi Alex

    I need to create a form to add and edit content, so I would use the Surface Controller to submit a form. But if I edit content, it would be a patch and not a post method. That's why I was wondering if I could use the Surface Controller for all CRUD operations. I wanted to use the Surface Controller because I think it's a cleaner way than using the Umbraco API Controller.

    Thank you!

Please Sign in or register to post replies

Write your reply to: