Facebook CanvasAutorize SDK attribute redirects my ajax call and doesn't reach controller code

I have an FB application that works fine with postbacks from MVC, but when I try to send some data to a controller that has a requireauthorize attribute using jquery $ .post (), FB redirects it and I can’t get it to work It only returns a block of script code, which I believe is a reference to FB or something like that.

Example: user interface button. Click Code

//Client side JS button click event
$.post("/Friends/Save", "{ 'requestIds':'"+ response.request_ids + "'}", function (data) {
    alert("Friend requests saved!");
});

My MVC controller code:

[HandleError]
public class FriendsController : Controller
{
    [CanvasAuthorize(Perms = "user_about_me")]
    public JsonResult Save(string requestIds)
    {
        //Save to DB
        //(....)

        return Json(new { Status = "Saved!" });
    }
}

If I comment on an attribute, everything works fine. Anyone can help me on how this can be done? I need to check every record that he performed as a registered user of FB!

Thanks in advance! Have a nice day everyone!

+3
1

. , Get Post ( [AcceptVerbs (HttpVerbs.Get)] [AcceptVerbs (HttpVerbs.Post)]) [CanvasAuthorize] Get. ajax, , .

+2

Source: https://habr.com/ru/post/1792194/


All Articles