How to connect to facebook and debug facebook application using C # SDK

I am really trying to find something that really works in order to raise the basics. Even the training applications that ship with the SDK seem to have to be loaded to work, so there is no easy way to debug and test it locally.

Has anyone got a link to a working sample that I could work with?

Hooray!


This is what I have in my aspx. Nothing left in the code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="FacebookTest.WebForm1" %> <%@ Import Namespace="Facebook" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <head runat="server"> <title></title> </head> <body> <p> </p> <% var app = new FacebookApp(); if (app.Session == null) {%> <img id="fbLogin" src="login-button.png" /> <% }%> <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({ appId: '<%:FacebookSettings.Current.AppId %>', status: true, cookie: true, xfbml: true }); $('#fbLogin').click(function () { FB.login(function (response) { if (response.session) { //window.location = '<%--:Url.Action("Profile") --%>' } else { // user cancelled login } }); }); </script> </body> </html> 
+4
source share
1 answer

I am also struggling with this sdk. For local testing you should do the following

  • In the settings of the Facebook application, go to the "Website" tab and change the website URL to "http: // localhost /"
  • You also need to set the asp.net development server port to 80 (click the β€œclick” button on your projects and click properties, go to the β€œWeb tab” tab. We do this because we set the URL of our site to localhost, Facebook does not allow the port number in the site URL.
+3
source

All Articles