Problem when posting back to mvc 3.0 facebook app
I have set开发者_运维问答up 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?
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"] %>" />
精彩评论