Facebook是否通过“发布"请求打开画布应用程序?我的MVC动作造成了严重破坏 [英] Does Facebook open a canvas app with a Post request? It's causing havoc with my MVC actions

查看:46
本文介绍了Facebook是否通过“发布"请求打开画布应用程序?我的MVC动作造成了严重破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个具有Friend视图的MVC应用,该视图具有后期操作,请参见下面的代码.当我第一次加载页面时,将调用我的POST方法.我发现了这个 http://developers.facebook.com/docs/canvas/post/并想知道是否有人可以澄清Facebook正在调用post方法来传递数据.在哪种情况下,解决问题的最佳方法是重命名POST操作?

I've created an MVC app that has a Friend view which has a post action, see code below. When I'm loading the page for the first time my POST method is getting called. I found this http://developers.facebook.com/docs/canvas/post/ and just wondered if someone could clarify that Facebook is calling the post method to pass in data. In which case the best way around my problem is to rename my POST action?

这是我的代码,其中删除了不必要的位:

Here's my code with unnecessary bits stripped out:

public ActionResult Friend()
    {
        ViewData["Success"] = false;
        return View("Friend");
    }
    [HttpPost]
    public ActionResult Friend(FacebookViewModel model)
    {
        ViewData["Success"] = true;
        return View("Friend", model);
    }

调用应用程序时,正在打印到屏幕上的ViewData将打印"true".:(

When calling the app ViewData being printed out to the screen is printing 'true'. :(

推荐答案

出于安全原因,我相信Facebook会这样做,我记得不久前看到过有关将画布应用切换为POST的一些信息.

I believe Facebook does this for security reasons, I remember seeing something about the switch to POST for canvas apps a while back.

好像他们也在此博客文章中宣布的那样.

Looks like they also announced it in this blog post.

最好的选择可能是按照您的建议更改操作:

The best option is probably to change your Action as you suggested:

[HttpPost]
public ActionResult CanvasLoad(FacebookPostLoadViewModel model)
{
    // Do your load logic and show your view or RedirectToAction("Otherview");
    return View("Friend", model);
}

这篇关于Facebook是否通过“发布"请求打开画布应用程序?我的MVC动作造成了严重破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆