public class FbFriend { public string Id { get; set; } public string Name { get; set; } public string Link { get; set; } public User AppUser { get; set; } }
The field "AppUser" will be initialized right after the request if my FbFriend is an user in my application. However, I was constantly getting an error. Even worse - I couldn't see wher the exception occured. For instance, I had this code:
var task = ctx.Client.GetCurrentUserAsync<FbUser>(); task.Wait(); var user = task.Result;
And all that I could see is that my user object had all nulls for fields. First step is seeing how to locate an error - assuming one develops with Visual Studio 2012, here is the screenshot:
Using mouse over on your context object, navigate to http request:
Copy paste entire URL into browser and read the result:
In my case, field AppUser is unknown. The last step is to tell the Facebook.Mvc to ignore field AppUser. It does not work with IgnoreDataMember, nor it works with NonSerialized attribute, but works only with JsonIgnore:
public class FbFriend { public string Id { get; set; } public string Name { get; set; } public string Link { get; set; } [JsonIgnore] public User AppUser { get; set; } }Problem: [solved].
Nema komentara:
Objavi komentar