I have a FB app that is working nice with the postbacks from within MVC but when i try to post some data to a controler that has the requireauthorize attribute, using jquery $.post() , FB redirects it and I can’t get it work. It only returns a block of script code instead, which i believe is the ridirection from FB or something.
Example: UI 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 the attribute everything works fine, Anyone can help me out on how can this be done ?
I need to check for every post that it is done by a FB logged in user!
Thanks in advance! Have a good day all!
I experienced this same issue. My solution was to separate the Get and Post controller methods (via [AcceptVerbs(HttpVerbs.Get)] and [AcceptVerbs(HttpVerbs.Post)] ) and only put the [CanvasAuthorize] attribute on the Get method. When I perform my ajax Post I include the signed request in the post which I can use to get the access token.