Facebook app getting an HTTP 500.23 error; Translation?
I'm building my first facebook app, and I'm having a problem, I'm too new to this whole thing to understand whats going on, and was hoping someone more experienced may understand. Here is a link to the app, and the error:
http://apps.facebook.com/nowiknow/
Error:
HTTP Error 500.23 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
I'm hosting my app on DiscountASP.Net (littleappbin.com/whoremovedme/). My application pool pipeline mode is configured to Integrated, and the server is using IIS7. As far as I can tell, my code successfully asks for the required permissions, but when being redirected to the app 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 the C# on the backend 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!
开发者_如何学Python 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, a good majority of it is from different samples that I'm hacking around with.
Basically, you have a whole bunch of stuff mixed together that doesn't go together. Specifically, all of your assemblies listed are .net 3.5 assemblies, yet you have your compilation set to 4.0. Change your web.config file to this:
<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" />
</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>
Also make sure you have your Framework target set to 4.0. See here for details: http://msdn.microsoft.com/en-us/library/bb398197.aspx
精彩评论