Copied to clipboard

Flag this post as spam?

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


  • Sharif Hassan 11 posts 101 karma points
    Oct 04, 2022 @ 09:02
    Sharif Hassan
    0

    how to use Ajax POST with Umbraco 10.2

    Am using Umbraco 10.2 am trying to do Ajax Post without using BeginUmbracoForm.

    I try with Ajax by JavaScript and also with HTML AjaxBeginForm my controller is inherit from SurfaceController.

    In both cases I got this erorr "The required request field "ufprt" is not present."

    i just wanna ask if there is possibility to use ajax post with Umbraco and if yes how archive it.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Oct 04, 2022 @ 09:26
    Huw Reddick
    100

    you can add [IgnoreAntiforgeryToken] to your controller action

  • Sharif Hassan 11 posts 101 karma points
    Oct 04, 2022 @ 09:45
    Sharif Hassan
    0

    Thanks it is working for me :)

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Oct 04, 2022 @ 10:17
    Huw Reddick
    3

    If you want to use the antiforgery validation, you can add the following to your ajax request

    beforeSend: function (xhr) {
        xhr.setRequestHeader("RequestVerificationToken",
        $('input:hidden[name="__RequestVerificationToken"]').val());
    },
    
Please Sign in or register to post replies

Write your reply to:

Draft