Copied to clipboard

Flag this post as spam?

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


  • J 419 posts 785 karma points
    1 week ago
    J
    0

    Does Umbraco handle attributes for a custom section?

    Hi

    I have created a custom section which is built using AngularJS and Entity Framework.

    I am inheriting from UmbracoAuthorizedJsonController in my custom section controller.

    I have a method which saves some data using logic i have created within my Entity Framework class. This saves to my database successfully.

    Does my method to save data need to be decorated by attributes such as [HttpPost] or does Umbraco handle this?

  • Lucas Bisgaard 6 posts 71 karma points
    1 week ago
    Lucas Bisgaard
    100

    Hello J,

    No Umbraco isn´t handling the as [HttpPost] or [HttpGet] if you follow the UmbracoAuthorizedJsonControllerimplementation you´ll find the MVC ApiContoller.

    Umbraco is trying to be close to what MVC would normally do, with some modification.

    //L

  • J 419 posts 785 karma points
    1 week ago
    J
    0

    Thanks Lucas, so i should still implement all attributes as necessary myself i.e. [HttpGet], [HttpPost] etc?

    Would you happen to know if the [Authorise] attribute would work in Umbraco the same way it does for MVC apps or is this not necessary as UmbracoAuthorizedJsonController is already taking care of that?

  • Lucas Bisgaard 6 posts 71 karma points
    1 week ago
    Lucas Bisgaard
    1

    No need to make a custom implementation of the attributes. You can simply ref the using of using System.Web.Http;

    And there is no need for the [Authorize] attribute when you inhrites the class UmbracoAuthorizedJsonController to your controller.

    The UmbracoAuthorizedJsonController is build in to only allow authorize Umbraco users. Read more here: https://our.umbraco.com/Documentation/Reference/Routing/Authorized/#routing-requirements-for-backoffice-authentication

    If it is members you working with at the UmbracoApiController and need to check authentication, then read more here: https://our.umbraco.com/Documentation/Reference/Routing/Umbraco-API-Controllers/authorization-v7

Please Sign in or register to post replies

Write your reply to:

Draft