示例#1
0
        public void LoginTwitter()
        {
            // Make sure session ID is initialized
            // ReSharper disable UnusedVariable
            var sessionId = Session.SessionID;
            // ReSharper restore UnusedVariable

            var twitterSignIn = new TwitterConsumer().TwitterSignIn;

            var uri = new Uri(new Uri(AppConfig.HostAddress), Url.Action("LoginTwitterComplete"));
            var request = twitterSignIn.PrepareRequestUserAuthorization(uri, null, null);
            var response = twitterSignIn.Channel.PrepareResponse(request);

            response.Send();
            Response.End();
        }
示例#2
0
        public ActionResult LoginTwitter()
        {
            // Make sure session ID is initialized
            // ReSharper disable UnusedVariable
            var sessionId = Session.SessionID;
            // ReSharper restore UnusedVariable

            var twitterSignIn = new TwitterConsumer().TwitterSignIn;

            var uri = new Uri(new Uri(AppConfig.HostAddress), Url.Action("LoginTwitterComplete"));

            UserAuthorizationRequest request;

            try {
                request = twitterSignIn.PrepareRequestUserAuthorization(uri, null, null);
            } catch (ProtocolException x) {

                log.ErrorException("Exception while attempting to send Twitter request", x);
                TempData.SetErrorMessage("There was an error while connecting to Twitter - please try again later.");

                return RedirectToAction("Login");

            }

            var response = twitterSignIn.Channel.PrepareResponse(request);

            response.Send();
            Response.End();

            return new EmptyResult();
        }