Is a ConnectSession object the way to go when I have a FB SessionId?

Nov 24, 2009 at 3:29 PM

I have a stand-alone mvc website, detached from Facebook in other ways that I use a  want to use the Facebook API to fetch stuff for my users.

I use a 3rd party component ( to control site login.  The login procedure delivers me, among other things, the user's Facebook Id  and sessionId.

Using the toolkit I have been trying to create a ConnectSession object to be the base of my Facebook interaction. This fails  (see thread

Am I going about this the wrong way?

Is there another way to connect to Facebook than creating the ConnectSession object? 



Nov 24, 2009 at 5:03 PM

Can you try something like:


Facebook.Session.ConnectSession ConnectSession = new Facebook.Session.ConnectSession(APIKey, APISecret);
Facebook.Rest.Api Api = new Facebook.Rest.Api(ConnectSession);
Api.Session.SessionKey = MyUserSessionKey; // the session key you saved 
Api.Session.UserId = MyUserID; // the userid you saved
var FBUser = api.Users.GetInfo();

That works for me in a console app I am building.


Nov 24, 2009 at 9:23 PM

Thanks for your reply ... your code describes exactly what I wanted to do. But it fails during that first line (new ConnectSession(API.....) as I mentioned here :) 

So I am basically trying to find an alternative or trying to get confirmed that this is THE way to go and just have to bite-it and deal with the "Unable to populate Facebook Connect Session/User cookie information" exception.

Nov 25, 2009 at 4:33 PM

I think if that line fails you might have something off in your installation.

You are using your APIKey and API Secret for your facebook app, when you instantiate the ConnectSession, right?

Are you using ASP.NET 2.0 Integrated Pipeline?  That is what I am using...but I think that might be an MVC requirement, not a FDT requirement.  Something to try though.

Nov 28, 2009 at 7:31 PM

Yebss, I am using the APIKey and API secret key, which worked fine with an 2.[something] version of the toolkit.

 I am indeed using the 2.0 Integrated Pipeline Mode on the IIS7.

This has something to do with my IIS/Windows 7 setup... I just haven't been able to figure out what it is.... so I am just fishing for ideas as I haven't been able to find anything on this issue.

Anyone... ? :)


Nov 29, 2009 at 5:03 PM

Why don't you post the simplest possible (least number of lines of code) repro test case so we can see exactly what your code is doing?

Nov 29, 2009 at 7:36 PM
Edited Nov 29, 2009 at 7:45 PM


         public ActionResult Index()
             Facebook.Session.ConnectSession ConnectSession = new Facebook.Session.ConnectSession(Config.APIKey, Config.Secret);              
             return View();


It's really just as basic as it gets ... the index action of an mvc controller.

public ActionResult Index()

Facebook.Session.ConnectSession cs = new Facebook.Session.ConnectSession(Config.APIKey, Config.Secret); //I have verified that these keys are returned correctly

[code missing from here as I never reach this point ..]


return View();


The Facebook code line results in: 

Unable to populate Facebook Connect Session/User cookie information.



Nov 29, 2009 at 11:16 PM

Probably not much consolation, but I did just try that in my MVC app and it did work fine for me. 

Are you building with the latest toolkit source, not just the released version?  

Nov 30, 2009 at 8:07 AM

Thanks for your feedback all ... I have managed to fix this.  What I suspect was the issue was the following.

When looking at properties for the facebook.dll file in Windows Explorer (Windows 7), there is a new property under the "General" tab which says:  

"This file came from another computer and might be blocked to help protect this computer." 

Then there is a button with an "Unblock" title.

After clicking the "Unblock" button, this property disappears. I am not sure what unblocking this this actually does, but at least my ConnectSession(...) works perfectly now.

Just to be clear, I also played around a bit with other security issues (i.e. adding FullControl permissions for Everyone), but I have rolled back all those changes and cleaned the solution and restarted IIS, and the SessionConnect(..) still works. 

Nov 30, 2009 at 3:37 PM

Good to hear you figured it out.  Sounds like you downloaded the binaries.  You might want to get the latest source, since there were a few bug fixes for session management checked in on Nov 11, and building from source is the only way you'll get them.