FDT 3.0 MVC sample - Fbml.TabItem helper producing incorrect URLs

Oct 29, 2009 at 8:26 PM
Edited Oct 30, 2009 at 11:44 AM

In Kevin Marshall's MVC sample:

http://blogs.claritycon.com/blogs/kevin_marshall/archive/2009/10/06/facebook-developer-toolkit-3-0-asp-net-mvc-sample.aspx

He created a helper called Fbml.TabItem that renders a <fb:tab-item> tag.  However, the href for this tag doesn't seem to be generated correctly.  It generates a URL that is relative to the application, but apparently the <fb:tab-item> tag requires the href to start with http://apps.facebook.com/yourapppath/.  This is easy enough to change, but this alone doesn't quite solve the problem if the application is running in a virtual directory because UrlHelper.Action returns the virtual directory as part of the path.  Facebook strips the http://apps.facebook.com/yourapppath/ from the URL and replaces it with the Canvas Page URL set in the app settings.  This means the virtual directory ends up in the path twice. 

An example might make this easier to understand.  Assume I have a Facebook app with the following Canvas Page URL:

http://apps.facebook.com/myapp/

And the following Canvas Callback URL:

http://www.myapp.com/virtualdirectory/

If I set the href of the fb:tab-item tag like this:

href = "http://apps.facebook.com/myapp" + new UrlHelper(vc.RequestContext).Action(actionName, controllerName);

The href gets set to:

http://apps.facebook.com/myapp/virtualdirectory/controller/action

Facebook removes the Canvas Page URL (http://apps.facebook.com/myapp) and adds the Canvas Callback URL so we end up with:

http://www.myapp.com/virtualdirectory/virtualdirectory/controller/action

And it then tries to retrieve the FBML from this URL.  Virtualdirectory is duplicated, leading to a 404.

Anyone know an elegant way to solve this?