Copied to clipboard

Flag this post as spam?

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


  • Johannes Lantz 156 posts 838 karma points c-trib
    Oct 26, 2019 @ 12:38
    Johannes Lantz
    0

    Contact form, UmbracoApiController vs UmbracoSurfaceController

    Hello evryone!

    I have been working with Umbraco 7 for quite a while now. And I have come across diffrent ways to create a contact form.

    One uses the UmbracoApiController. And types the method in the controller to a string, and returns:
    return SerializeObject(new { success = true });
    And to get the fields of the form uses: Current.Request.Form["name"];.


    And one uses the UmbracoSurfaceController, Creates an view model and in the controller types the method to an ActionResult and passes in the model. And returns either a partial views if it's an ajax call or return RedirectToCurrentUmbracoPage();. And to get the fields of the form uses: model.Name.


    So my question is: Is one of these option better than the other or is one way more preffer that the other, or how do you create your form?


    My opinon is that using the UmbracoApiController is a bit faster to write and more dynamic if you want to do hotfixes when in production, or just to add fields.

    Would love you know you guys opinions!

    //Johannes

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Nov 11, 2019 @ 12:38
    Alex Skrypnyk
    101

    Hi Johannes

    Api is for Api

    Surface controllers is for forms and for child view logic.

    But all other is just your preferences.

    Thanks, Alex

Please Sign in or register to post replies

Write your reply to:

Draft