响应重定向工作失败

本文关键字:失败 工作 重定向 响应 | 更新日期: 2023-09-27 18:04:03

我想从客户端传递FB响应到服务器端(后面的代码)

 function testAPI() {
            console.log('Welcome!  Fetching your information.... ');
            FB.api('/me', function (response) {
                $.post('http://localhost:4741/Default.aspx',
                { fbid: response.id, firstname: response.first_name, lastname: response.last_name, email: response.email, bday: response.birthday }, 
                function (result) {
                });
                 console.log('Good to see you, ' + response.id + response.name + response.id + response.email + response.gender + response.birthday + '.');
            });
        }

我想在页面加载

中获得值和过程
protected void Page_Load(object sender, EventArgs e)
        {
            var fbid = Request.Form["fbid"];
            var fname = Request.Form["firstname"];
            var lname = Request.Form["lastname"];
            var email = Request.Form["email"];
            var bday = Request.Form["bday"];
            if (!Page.IsPostBack)
            {
                if (fbid != null)
                {
                    if (CheckFBLogin(fbid.ToString()) == true)
                    {
                        Response.Redirect("Users.aspx");
                    }
                    else
                    {
                        Response.Redirect("Register.aspx");
                    }
                }
            }

        }

CheckFBLogin(fbid.ToString())是位于页面后面相同代码中的函数。但是当传递Response.Redirect("Register.aspx",true);什么也没发生。它会留在同一个页面。

应该修复什么?

响应重定向工作失败

您正在将'endResponse'参数中的'true'传递给Response.Redirect。这将导致当前请求结束,导致ThreadAbortException。如果你不处理这个,或者你通过简单地吞下异常来处理它,你的重定向将会出现"不工作"。