开发者

Facebook C# SDK - Issues when redirecting to another page

I have an IFrame Facebook applicagtion (asp.net / Facebook C# SDK http://facebooksdk.codeplex.com/). Default page works fine. I use the foolowing code to authenticate:

IFacebookSettings FbSettings = FacebookSettings.Current;
FacebookApp Fb = new FacebookApp(FbSettings);
CanvasAuthorizer FbAuthorizer = new CanvasAuthorizer(Fb);

if (!FbAuthorizer.IsAuthorized())
{
    Response.Redirect("~/Login.aspx?returnUrl=" + HttpUtility.UrlEncode(Request.Url.PathAndQuery));
    Res开发者_开发百科ponse.End();
}
else
{
    CurrentUser = new FacebookUser((JsonObject)Fb.Api("/me"));
    CurrentUser.AccessToken = Fb.AccessToken;
}

this code is in BasePage class OnInit that is derived from System.Web.UI.Page. Other pages are derived from BasePage

On first load (default.aspx) the authentication suceedes (user gets redirected to login page, and then automatically redirected back, like in example provided in SDK).

So, when the homepage (default.aspx) is finally loaded, i press a hyperlink that is on the page. The hyperlink navigates the IFrame to another aspx file in a subfolder that is also derived from BasePage class.

Here is where the problem occurs:

When the second (inner) aspx gets loaded, it gets redirected to logn page too and then back. In some cases (Internet explorer / Safari) i get an infinire redirect to login and back to inner page.

what am i doint wrong?

EDIT: I had an invalid canvasUrl setting in web.config that was pointing to an invalid URL, this question should be considered closed.


Upgrade to the latest version of the Facebook C# SDK (5.0.1). This should solve your problem.


change this in your web.config It allows you to keep session when you redirect page

 <system.web>
<compilation debug="true" targetFramework="4.0" />
<pages enableViewState="true" validateRequest="false" />
<httpRuntime requestValidationMode="2.0"/>
<!--<sessionState cookieless="true" regenerateExpiredSessionId="true" />-->

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜