Wednesday, April 2, 2014

How to add Facebook login function into ASP.NET MVC project?

Step 1: create a Facebook app, and get appid
Step 2: Add following code into login view file


Step 3: Create an action in AccountController
        [HttpGet]
        public ActionResult FacebookLogin(string token)
        {
            WebClient client = new WebClient();
            string JsonResult = client.DownloadString(string.Concat(
                   "https://graph.facebook.com/me?access_token=", token));

            var serializer = new JavaScriptSerializer();
            dynamic value = serializer.DeserializeObject(JsonResult);
            
            var model = new RegisterModel()
            {
                Email = value["email"],
                FirstName = value["first_name"],
                LastName = value["last_name"]
            };

            FormsAuthentication.SetAuthCookie(model.Email, true /* createPersistentCookie */);
            return RedirectToAction("Index", "Home");
        }

How to solve problem, Given URL is not allowed by the Application configuration Facebook application error?

Go to https://developers.facebook.com/
->Your app ->Settings -> Addvanced -> Valid OAuth redirect URIs -> put your login url in here

How to create a web page screenshot by Javascript lib, html2canvas

http://html2canvas.hertzen.com/screenshots.html

What Javascript Frameworks are used at Twitter.com?

http://vitalflux.com/ui-frameworks-used-twitter-com/

DropzoneJS, an open source library that provides drag'n'drop file uploads with image previews

http://www.dropzonejs.com/