Problem when posting back to mvc 3.0 facebook app

女生的网名这么多〃 提交于 2019-12-13 01:43:58

问题


I have setup a facebook app, configured it to point to my localhost and created a tab in facebook to point to the local app.

All works fine and the initial load renders my page fine and the user is authenticated when I check FacebookWebContext.Current.IsAuthenticated().

My problem is that when I post data back, the facebook context is lost and FacebookWebContext.Current.IsAuthenticated() returns false.

Not sure if I am missing something here, but surely I should be able to post back to controller actions and stay authenticated?


回答1:


you need to manually maintain the signed request for post backs.

<% if(!string.IsNullOrEmpty(Request.Params["signed_request"])) { %>
    <input type="hidden" name="signed_request" value="<%= Request.Params["signed_request"] %>" />
<% } %>

Refer to this discussion on more information http://facebooksdk.codeplex.com/discussions/255100

You could also use this html helper extensions method

@FacebookSignedRequest()

instead of

<input type="hidden" name="signed_request" value="<%= Request.Params["signed_request"] %>" />


来源:https://stackoverflow.com/questions/6761289/problem-when-posting-back-to-mvc-3-0-facebook-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!