Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4116424
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:42:23+00:00 2026-05-20T22:42:23+00:00

I’ve got my ASP.NET MVC 3 Web Application up and running with the Facebook

  • 0

I’ve got my ASP.NET MVC 3 Web Application up and running with the Facebook C# SDK.

Following the instructions here, it seems as though once you put in the AppId / Secret in the web config section instructed, that is the settings pulled back when using FacebookApplication.Current, e.g:

var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current) 
{
   RedirectUri = new Uri(RedirectUrl)
};

My Web Application is “white labeled” so it serves two websites, with two seperate Facebook Applications.

Previously when i implemented Facebook Connect, i had a global property called “FacebookApplicationId”, which looked at the domain and worked out which app id to use.

Is there a graceful way to do this with the Facebook C# SDK?

I could just do this:

var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current) 
{
     RedirectUri = new Uri(RedirectUrl),
     AppId = ManuallyGetTheRightAppIdBasedOnDomain(),
     AppSecret = ManuallyGetTheRightAppSecretBasedOnDomain()
};

But that seems un-DRY as i’ll have to keep doing that.

Is there a way i can put some smarts in FacebookApplication.Current, so that the AppId and AppSecret properties are already set?

Open to any and all suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:42:24+00:00Added an answer on May 20, 2026 at 10:42 pm

    Think i got it: the ctor for FacebookOAuthClient takes a IFacebookApplication.

    So i created a concrete implementation called WhiteLabeledFacebookApplication, which implements IFacebookApplication.

    WhiteLabeledFacebookApplication‘s ctor takes a WebsiteType enum, so the properties for AppId and AppSecret read the relevant values from the web.config based on the enum passed through in the ctor.

    So, in my FacebookController, (where i do all the FB stuff), i have a private property called CurrentFacebookApplication:

    private IFacebookApplication _currentFacebookApplication;
    private IFacebookApplication CurrentFacebookApplication
    {
       get
       {
          if (_currentFacebookApplication == null)
          {
             var websiteType = SomeUnimportantCodeWhichWorksOutWebsiteFromUrl();
             _currentFacebookApplication = new WhiteLabeledFacebookApplication(websiteType );
          }
    
          return _currentFacebookApplication;
       }
    }
    

    So i can do this:

    var oAuthClient = new FacebookOAuthClient(CurrentFacebookApplication) 
    {
       RedirectUri = new Uri(RedirectUrl)
    };
    

    And the correct AppId/Secret will be pulled back – groovy!

    The only thing i wish i could do is use dependency injection, but during construction of controllers, there is no HttpContext so i can’t work out the website type.

    Still, works well – fairly DRY.

    Hats off to the developers for the toolkit for using interface-driven programming.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a JSP page retrieving data and when single or double quotes are
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.