I am creating my first facebook app and I have a problem, I am too new to this to understand what is happening and was hoping that someone more experienced could understand. Here is the application link and error:
http://apps.facebook.com/nowiknow/
Error:
HTTP Error 500.23 - Internal Server Error. An ASP.NET configuration has been discovered that does not apply to Integrated Managed Pipeline Mode.
I host my application on DiscountASP.Net (littleappbin.com/whoremovedme/). My application pool configured to Integrated , and the server uses IIS7 . As far as I can tell, my code successfully asks for the required permissions, but when redirecting to the application, something goes wrong.
Here is my web.config file :
<configuration> <configSections> <section type="Facebook.FacebookConfigurationSection, Facebook" name="facebookSettings" allowLocation="true" allowDefinition="Everywhere" /> <section name="canvasSettings" type="Facebook.Web.CanvasConfigurationSettings, Facebook.Web" /> </configSections> <facebookSettings appSecret="xxxxxxxxxx" appId="xxxxxxxxxxxxxx" cookieSupport="true"/> <canvasSettings canvasPageUrl="http://apps.facebook.com/nowiknow" canvasUrl="http://www.littleappbin.com/whoremovedme" authorizeCancelUrl="http://facebook.com"/> <system.web> <compilation debug="true" targetFramework="4.0" urlLinePragmas="true"> <assemblies> <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.DirectoryServices.Protocols, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Web.RegularExpressions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.Entity.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.Services.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies> <buildProviders> <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider"/> </buildProviders> </compilation> <httpHandlers> <add verb="*" path="facebookredirect.axd" type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web" /> </httpHandlers> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> <handlers> <add name="facebookredirect.axd" verb="*" path="facebookredirect.axd" type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web" /> </handlers> </system.webServer> <connectionStrings> <add name="xxxxxConnectionString" connectionString="Data Source=xxxxx;Initial Catalog=xxxxx;Persist Security Info=True;User ID=xxxxx;Password=xxxxxx" providerName="System.Data.SqlClient"/> </connectionStrings> </configuration>
Here is C # on the server of my page:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Facebook; using Facebook.Web; using System.Collections; public partial class _Default : Page { protected string requiredAppPermissions = "offline_access,user_about_me"; protected FacebookApp fbApp; protected CanvasAuthorizer authorizer; protected void Page_Load(object sender, EventArgs e) { fbApp = new FacebookApp(); authorizer = new CanvasAuthorizer(fbApp); authorizer.Perms = requiredAppPermissions; if (authorizer.Authorize()) { //Authorized! dynamic myInfo = fbApp.Get("me"); lblName.Text = "<b>" + myInfo.name + "</b>!"; UpdatePanel1.Visible = false; } } private void ShowFacebookContent() { if (!Page.IsPostBack) { dynamic myInfo = fbApp.Get("me"); JsonArray myFriends = (JsonArray)((JsonObject)fbApp.Get("me/friends"))["data"]; lblFriendCount.Text = "<b>" + myFriends.Count.ToString() + "</b>"; //Record any new facebook friends AddFacebookFriends(myInfo.id, myFriends); //Populate the Previous friends DDL PopulatePreviousFriendsDDL(myInfo.id); //Populate the New Friends DDL PopulateNewFriendsDDL(myFriends); //Display the Missing Friends list CalculateMissingFriends(); } } private void CalculateMissingFriends() { bool matched; foreach (ListItem oldFriend in ddlPreviousFriends.Items) { matched = false; foreach (ListItem newFriend in ddlNewFriends.Items) { if (oldFriend.Value == newFriend.Value) { matched = true; break; } } if (!matched) { //This friend has either been deleted, or has deleted the user dynamic friendData = fbApp.Get(oldFriend.Value); lblMissingFriends.Text += "<a href='" + friendData["link"].ToString() + "' target='_blank'>" + oldFriend.Text + "</a><br/>"; } } if (String.IsNullOrEmpty(lblMissingFriends.Text)) { lblMissingFriends.Text = "No Friends are missing!"; } } private void PopulateNewFriendsDDL(JsonArray friends) { foreach (JsonObject friend in friends) { ddlNewFriends.Items.Add(new ListItem(friend["name"].ToString(), friend["id"].ToString())); } } private void PopulatePreviousFriendsDDL(string userID) { FriendsDataContext friendDb = new FriendsDataContext(); var query = from dbFriends in friendDb.Friends where dbFriends.UserID == userID select dbFriends.FriendID; ListItem friendItem; foreach (string friendID in query) { dynamic friend = fbApp.Get(friendID); ddlPreviousFriends.Items.Add(new ListItem(friend["name"].ToString(), friendID)); } } private void AddFacebookFriends(string userID, JsonArray friends) { FriendsDataContext friendDb = new FriendsDataContext(); var query = from dbFriends in friendDb.Friends where dbFriends.UserID == userID select dbFriends.FriendID; bool matched; string lastFriendID = String.Empty; foreach (JsonObject friend in friends) { matched = false; lastFriendID = friend["id"].ToString(); foreach(string friendID in query) { if (lastFriendID == friendID) { matched = true; break; } } if (!matched) { //Add this friend friendDb.Friends.InsertOnSubmit(new Friend { ID = System.Guid.NewGuid().ToString(), UserID = userID, FriendID = lastFriendID }); } } friendDb.SubmitChanges(); } protected void btnRecordFriends_Click(object sender, EventArgs e) { btnRecordFriends.Visible = false; ShowFacebookContent(); UpdatePanel1.Visible = true; } }
I apologize for the messy code, and most of it is from different samples with which I crack.