如何从URL解析访问令牌

时间:2012-01-05 20:55:35

标签: facebook-c#-sdk access-token

我收到以下网址:

http://localhost:8080/facebook/Status#access_token=dsadsa

我尝试在方法Status()中解析它,但变量“Request.Url”是

http://localhost:8080/facebook/Status

如何解决这个问题?

 public ActionResult Status()
        {
            FacebookOAuthResult result;                
            if (FacebookOAuthResult.TryParse(Request.Url, out result))
            {
                if (result.IsSuccess)
                {
                    var accessToken =  result.AccessToken;
                    var code = result.Code;
                    var app = new FacebookClient(fbm.appID, fbm.appSecret);
                    fbm.accessToken = app.AccessToken;
                    ViewData["accessToken"] = app.AccessToken;
                    fbm.isAuthorized = true;

                }
                else
                {
                    var errorDesc = result.ErrorDescription;
                    var errorReason = result.ErrorReason;
                    fbm.isAuthorized = false;
                    ViewData["errorDesc"] = errorDesc;
                    ViewData["errorReason"] = errorReason;
                }       
            }          
            return View();
        }

1 个答案:

答案 0 :(得分:1)

您可以在此处ASP.NET: parse url having # (hash) sign看到请求对象不包含哈希标记。