Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net web api ASP.NET web API标识外部登录重定向_Asp.net Web Api_Asp.net Identity 2 - Fatal编程技术网

Asp.net web api ASP.NET web API标识外部登录重定向

Asp.net web api ASP.NET web API标识外部登录重定向,asp.net-web-api,asp.net-identity-2,Asp.net Web Api,Asp.net Identity 2,我使用ASP.NETWebAPI身份登录Facebook,我有angularjs应用程序 当我打电话时 MainURL + 'api/Account/ExternalLogins?returnUrl=%2F&generateState=true' 我不想返回web API页面,而是希望Facebook将我重定向回我的angularJS应用程序,所以我这样做了: [AllowAnonymous] [Route("ExternalLogins")] public IEnu

我使用ASP.NETWebAPI身份登录Facebook,我有angularjs应用程序

当我打电话时

MainURL + 'api/Account/ExternalLogins?returnUrl=%2F&generateState=true'
我不想返回web API页面,而是希望Facebook将我重定向回我的angularJS应用程序,所以我这样做了:

 [AllowAnonymous]
    [Route("ExternalLogins")]
    public IEnumerable<ExternalLoginViewModel> GetExternalLogins(string returnUrl, bool generateState = false)
    {
        IEnumerable<AuthenticationDescription> descriptions = Authentication.GetExternalAuthenticationTypes();
        List<ExternalLoginViewModel> logins = new List<ExternalLoginViewModel>();

        string state;

        if (generateState)
        {
            const int strengthInBits = 256;
            state = RandomOAuthStateGenerator.Generate(strengthInBits);
        }
        else
        {
            state = null;
        }

        foreach (AuthenticationDescription description in descriptions)
        {
            ExternalLoginViewModel login = new ExternalLoginViewModel
            {
                Name = description.Caption,
                Url = Url.Route("ExternalLogin", new
                {
                    provider = description.AuthenticationType,
                    response_type = "token",
                    client_id = Startup.PublicClientId,
                    redirect_uri = new Uri("http://localhost:6263/com.html").AbsoluteUri,
                   // redirect_uri = new Uri(Request.RequestUri, returnUrl).AbsoluteUri,
                    state = state
                }),
                State = state
            };
            logins.Add(login);
        }

        return logins;
    }

我肯定这已经晚了。看看你的url,它有一个双斜杠(//)

我确信这已经晚了。看看你的url,它有一个双斜杠(//)

/api/Account/ExternalLogin?provider=Facebook&response_type=token&client_id=self&redirect_uri=localhost%3A6263%2Fcom.html&state=j0y0wF0yhvA_tzqbJo0GijCecqfbNWT0vLQiXxcHDqM1