public
Last active

Multi-Tenant Facebook Application

  • Download Gist
Global.asax.cs
C#
1 2 3 4 5 6 7 8
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// Register your multi-tenant application on app startup
FacebookApplication.SetApplication(new MultiTenantFacebookApplication());
}
}
MultiTenantFacebookApplication.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
public class MultiTenantFacebookApplication : IFacebookApplication
{
 
private IFacebookApplication GetCurrent()
{
var url = HttpContext.Current.Request.Url;
// Get the settings based on the url or whatever
 
var simpleApp = new DefaultFacebookApplication();
 
// Set the settings
 
return simpleApp;
}
 
public string AppId
{
get { return GetCurrent().AppId; }
}
 
public string AppSecret
{
get { return GetCurrent().AppSecret; }
}
 
public string CancelUrlPath
{
get { return GetCurrent().CancelUrlPath; }
}
 
public string CanvasPage
{
get { return GetCurrent().CanvasPage; }
}
 
public string CanvasUrl
{
get { return GetCurrent().CanvasUrl; }
}
 
public string SiteUrl
{
get { return GetCurrent().SiteUrl; }
}
}

I want to host 2 facebook apps under one web app (each facebook app is a simple web page with almost the same logic so I'd like to have a web page per facebook app instead of having 2 separate web apps). Is it possible?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.