简体   繁体   中英

Facebook C# SDK Error An exception of type 'Facebook.WebExceptionWrapper'

I am trying to post on my Facebook page using this code but I get exception facebook.webexeptionwrapper and this the detailed message The underlying connection was closed: An unexpected error occurred when sending.

Here is my code:

 public ActionResult Send(FormModel model)
        {
            const string accesstoken = "myaccesstoken";

            dynamic messagePost = new ExpandoObject();
            messagePost.access_token = accesstoken;
            messagePost.picture = "https://miro.medium.com/max/1200/1*mk1-6aYaf_Bes1E3Imhc0A.jpeg";
            messagePost.link = "[SOME_LINK]";
            messagePost.name = model.titre;
            messagePost.caption = "user" + " this post was created by my website"; 
            
            messagePost.description = model.description;

            FacebookClient app = new FacebookClient(accesstoken);
          
                var result = app.Post("/" + model.pageId + "/feed", messagePost);
          
            return new EmptyResult();
        }

i solved by adding this line of code to my golabal.asax.cs

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 |SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | (SecurityProtocolType)3072;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM