title: Facebook integration with Asp .Net
body: <p>I need to integrate face book with my asp .net application. Here are the steps i have followed for it.</p>
  
  <ol>
  <li>I have created face-book application from face-book and got application key and secret key.</li>
  <li>I have used that application key and secret key in my application.</li>
  </ol>
  
  <p>here is my code :</p>
  
  <p>But in this code,  "Session["facebook_userId"]" is always giving me null value. can you tell me the reason for this ?</p>
  
  <p>protected void Page_Load(object sender, EventArgs e)
      {</p>
  
  <pre><code>    _fbService.ApplicationKey = FACEBOOK_APPKEY;
      _fbService.Secret = FACEBOOK_SECRET;
      _fbService.IsDesktopApplication = false;
  
      string sessionKey = Session["facebook_session_key"] as String;        
      userId = Session["facebook_userId"] as String;
  
      // When the user uses the facebook login page, 
      // the redirect back here will have the auth_token in the query params
      string authToken = Request.QueryString["auth_token"];
  
      if (!String.IsNullOrEmpty(sessionKey))
      {
          _fbService.SessionKey = sessionKey;
          _fbService.UserId = userId;
      }
      else if (!String.IsNullOrEmpty(authToken))
      {
          _fbService.CreateSession(authToken);
          Session["facebook_session_key"] = _fbService.SessionKey;
          Session["facebook_userId"] = _fbService.UserId;
          Session["facebook_session_expires"] = _fbService.SessionExpires;
      }
      else
      {
          Response.Redirect(@"http://www.facebook.com/login.php?api_key=" +
              _fbService.ApplicationKey + @"&amp;v=1.0");
      }
      if (!IsPostBack)
      {
          System.Collections.ObjectModel.Collection&lt;User&gt; userinfo = _fbService.GetUserInfo(_fbService.UserId);
          Label1.Text = userinfo[0].FirstName + "'s favorite shops";
          Image1.ImageUrl = userinfo[0].PictureUrl.ToString();
  
          // Use the FacebookService Component to populate Friends
          System.Collections.ObjectModel.Collection&lt;User&gt; Friends = _fbService.GetFriends();
          for (int i = 0; i &lt; Friends.Count; i++)
              DropDownList2.Items.Add(Friends[i].FirstName.ToString());
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Please help me for this !</p>