uid and sessionkey not being set

Oct 29, 2009 at 5:15 AM

I have been using the CanvasIFrameBasePage class and the IFrame option in my facebook application for my facebook app with the facebook developer toolkit. On Page_Load I was querying the SessionKey and Uid using the API like this:

long uid = API.uid;
string sessionKey = API.SessionKey;

When I run my application the uid and sessionKey variables are populated (I have tested with Response.Write()).

Now I want to start using CanvasFbmlBasePage but the exact same code does not work. When I run the code Response.Write() outputs 0 for the uid and "" for the sessionKey. Is there a reason this should be expected? What can I do to fix this?



Oct 29, 2009 at 8:36 PM

I found the problem. Here is the fix:

protected override void OnInit(EventArgs e)
    RequireLogin = true;


protected void Page_Load(object sender, EventArgs e)
    //RequireLogin = true;

    //_cherubPath = ConfigurationManager.AppSettings["WebRoot"] + "Cherub.aspx?Uid=" + API.uid + "&SessionKey=" + API.SessionKey;

I was setting RequireLogin in Page_Load, but the base class was using RequireLogin in the OnInit method. So, override OnInit and set RequireLogin before base.OnInit() is called.