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

  • SEARCH
  • Home
  • 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 8448417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:25:19+00:00 2026-06-10T10:25:19+00:00

I am totally new in using FB API and i am trying to post

  • 0

I am totally new in using FB API and i am trying to post to facebook wall from my Asp.net application.

I have got the Appkey and secret key from FB and just trying to follow
the code to post in FB wall.

LINK : http://kennetham.com/2010/07/21/facebook-api-asp-net/

The problem i am facing now is, in my ConnectAuthentication Class, HttpContext.Current.Request.Cookies[fullCookie] is always NULL. Due to that, when i check for the FB connectivity by “if (ConnectAuthentication.isConnected())” in my pageload, it always returns false and it does not run the code inside condition.

Why is that? Am i missing something ?

ConnectAuthentication Class

public class ConnectAuthentication
{
    public ConnectAuthentication()
    {

    }

    public static bool isConnected()
    {
        return (SessionKey != null && UserID != -1);
    }

    public static string ApiKey
    {
        get
        {
            return ConfigurationManager.AppSettings["APIKey"];
        }
    }

    public static string SecretKey
    {
        get
        {
            return ConfigurationManager.AppSettings["Secret"];
        }
    }

    public static string SessionKey
    {
        get
        {
            return GetFacebookCookie("session_key");
        }
    }

    public static long UserID
    {
        get
        {
            long userID = -1;
            long.TryParse(GetFacebookCookie("user"), out userID);
            return userID;
        }
    } 
    private static string GetFacebookCookie(string cookieName)
    {
        string retString = null;
        string fullCookie = ApiKey + "_" + cookieName; 

        if (HttpContext.Current.Request.Cookies[fullCookie] != null)
            retString = HttpContext.Current.Request.Cookies[fullCookie].Value;

        return retString;
    }
}

Here is how the ConnectAuthentication Class is used in my page load :

    if (ConnectAuthentication.isConnected())
                {
                    Facebook.Session.ConnectSession session = new Facebook.Session.ConnectSession(ConnectAuthentication.ApiKey, ConnectAuthentication.SecretKey);

                    _connectSession = new ConnectSession(ConnectAuthentication.ApiKey, ConnectAuthentication.SecretKey);

                    Api _facebookAPI = new Api(_connectSession);

                    _connectSession.UserId = ConnectAuthentication.UserID;
                    Facebook.Rest.Api api = new Facebook.Rest.Api(_connectSession);

                    //Display user data captured from the Facebook API.

                    Facebook.Schema.user user = api.Users.GetInfo();
                    string fullName = user.first_name + " " + user.last_name;
                    Panel1.Visible = true;
                    Label1.Text = fullName;

                }
                else
                {
                    //Facebook Connect not authenticated, proceed as usual.
                }
           }
  • 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-06-10T10:25:21+00:00Added an answer on June 10, 2026 at 10:25 am

    This code worked perfectly…

    <input type="button" id="fblogin" value="Login to Facebook" disabled="disabled" style="display:none"/>
            <fb:login-button v="2" length="long" onlogin="window.location = 'Default.aspx'">Login to Facebook</fb:login-button>
    
    <div id="fb-root"></div>
    <script>
        window.fbAsyncInit = function () {
            FB.init({
                appId: '<%: Facebook.FacebookApplication.Current.AppId %>',
                cookie: true,
                xfbml: true,
                oauth: true
            });
    
            function facebooklogin() {
                FB.login(function (response) {
                    if (response.authResponse) {
                        // user authorized
                        // make sure to set the top.location instead of using window.location.reload()
                        top.location = '<%= this.ResolveCanvasPageUrl("~/") %>';
                    } else {
                        // user cancelled
                    }
                }, { scope: '<%: string.Join(",", ExtendedPermissions) %>' });
            };
    
            $(function () {
                // make the button is only enabled after the facebook js sdk has been loaded.
                $('#fblogin').attr('disabled', false).click(facebooklogin);
            });
        };
        (function () {
            var e = document.createElement('script'); e.async = true;
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            document.getElementById('fb-root').appendChild(e);
        } ());
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm totally new in ASP.NET so I think it's an easy question I have.
I have an issue using the Location Api. I'm trying to get the Location
I am totally new to making ipad/iphone application. I am totally new to using
I'm totally new to ajax. I'm using VS2005. I just downloaded .NET framework 4
I'm totally new to the ASP.NET MVC stack, and I was wondering what happened
I'm totally new to django, and I'm using its documentation to get help on
I'm totally new to flex. I'm getting a build error when using flex. That
I'm totally new to Excel VBA. I am using Microsoft 2003 excel. What my
I am using Crystal Reports 2011. I am totally new to crystal reports and
Totally new to programming so kindly excuse the silly question. I have this URL

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.