Error when accessing applications Tab page.

Aug 3, 2010 at 2:24 AM
Edited Aug 3, 2010 at 2:26 AM
Hi,

I am trying to get a tab page going on my application and am running into the error "A session key is required for calling this method"

I'm using the latest build from source as at 2/8/2010.

My tab page inherits from CanvasFBMLBasePage and I think that the error occurs somewhere in the constructor for this.

at Facebook.Utility.Utilities.ParseException(String response, Boolean JSONFormat) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Utility\Utilities.cs:line 666
at Facebook.Rest.RestBase.processResponse(WebResponse webResponse, Boolean useJson) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Rest\RestBase.cs:line 508
at Facebook.Rest.RestBase.SendRequestSynchronous(IDictionary`2 parameterDictionary, Boolean useSession, Boolean useJson) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Rest\RestBase.cs:line 989
at Facebook.Rest.RestBase.SendRequest[T](IDictionary`2 parameterDictionary, Boolean useSession, Boolean useJson) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Rest\RestBase.cs:line 150
at Facebook.Rest.RestBase.SendRequest[T](IDictionary`2 parameterDictionary) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Rest\RestBase.cs:line 126
at Facebook.Rest.Users.GetLoggedInUser(Boolean isAsync, GetLoggedInUserCallback callback, Object state) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Rest\Users.cs:line 860
at Facebook.Rest.Users.GetLoggedInUser() in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Rest\Users.cs:line 172
at Facebook.Session.FacebookSession.get_UserId() in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Session\FacebookSession.cs:line 102
at Facebook.Session.CanvasSession.LoadFromRequest() in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Session\CanvasSession.cs:line 202
at Facebook.Session.CanvasSession.SetupCanvasSession(String appKey, String appSecret, List`1 permissions, Boolean readRequest) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Session\CanvasSession.cs:line 143
at Facebook.Session.CanvasSession..ctor(String appKey, String appSecret, List`1 permissions, Boolean readRequest) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Session\CanvasSession.cs:line 119
at Facebook.Session.CanvasSession..ctor(String appKey, String appSecret, Boolean readRequest) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Session\CanvasSession.cs:line 108
at Facebook.Session.CanvasSession..ctor(String appKey, String appSecret) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Session\CanvasSession.cs:line 90
at Facebook.Session.FBMLCanvasSession..ctor(String appKey, String appSecret) in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook\Session\FBMLCanvasSession.cs:line 19
at Facebook.Web.CanvasFBMLBasePage..ctor() in C:\akl-tfs01\FacebookToolkit\MAIN\Source\Facebook.Web\CanvasFBMLBasePage.cs:line 16
at visFacebookTicketing.visTab..ctor() in C:\akl-tfs01\Vista\Branches\_R03\FaceBook\main\visFacebookTicketing\visTab.aspx.designer.vb:line 0
at ASP.vistab_aspx..ctor()
at __ASP.FastObjectFactory_app_web_5vkfqkob.Create_ASP_vistab_aspx()
at System.Web.Compilation.BuildResultCompiledType.CreateInstance()
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Has anyone seen this behavior before?

Cheers,
Matt

Aug 6, 2010 at 7:22 PM
I have similar problem, created a mvc app and it works perfectly fine when viewed in full page mode, when user adds it as a tab it throws "A session key is required for calling this method" error. The app is only one page and I do not redirect user between actions or controllers. One controller, one action. Any ideas?
Aug 26, 2010 at 3:48 PM

There's a UsrId property on the CanvasSession class that requires a valid session key.  That property is being accessed before the session key is set.

In CanvasSession.cs, change the line

SetSessionProperties(                    sessionKeyFromRequest,                    UsrId,                    DateHelper.ConvertUnixTimeToDateTime(long.Parse(unixExpireTime)));

to

SetSessionProperties(                    sessionKeyFromRequest,                    long.Parse(inProfileTab ? HttpContext.Current.Request[QueryParameters.ProfileUser] : HttpContext.Current.Request[QueryParameters.User]),                    DateHelper.ConvertUnixTimeToDateTime(long.Parse(unixExpireTime)));

Probably not the most elegant solution, but it worked for me.