抛出异常:在Lumia 950XL设备上测试时,System.Private.CoreLib.ni.dll中出现'HttpRequestException'

时间:2017-11-12 21:30:44

标签: c# uwp azure-sql-database azure-mobile-services template10

我正在使用Azure使用facebook auth构建应用程序,现在,当我在本地计算机上的本地数据库上调试我的应用程序时,我的应用程序在登录我的应用程序时工作正常。

但是一旦我尝试在我的Lumia 950XL上测试它,有时它会成功登录,有时我根本不登录并告诉我这个:

  

单步执行:单步执行非用户代码   'Ceneam.Common.Helpers.AuthenticationDelegatingHandler.CloneHttpRequestMessageAsync'   步入:踩过非用户代码   'Ceneam.Common.Helpers.AuthenticationDelegatingHandler.d__1..ctor'   步入:踩过非用户代码   'Ceneam.Common.Helpers.AuthenticationDelegatingHandler。<> n__0'步骤   into:单步执行非用户代码   'Ceneam.Common.Helpers.LoggingHandler.SendAsync'步入:踏步   超过非用户代码   'Ceneam.Common.Helpers.LoggingHandler.d__2..ctor'
  要求:GET,   http://quicopc/Ceneam.Backend/tables/Account?$ skip = 0& $ top = 25 Step   into:单步执行非用户代码   'Ceneam.Common.Helpers.LoggingHandler。<> n__0'15:17:54.3412524   Template10 HamburgerMenu.GotFocus Windows.UI.Xaml.Controls.Button   名称:HamburgerButton符号:Windows.UI.Xaml.Controls.FontIcon
  抛出异常:'System.Net.Http.HttpRequestException'中   System.Private.CoreLib.ni.dll(此列表行连续4次)

现在我已经将我的应用程序调试到我的AuthenticationDelegatingHandler类,这是它走出的代码:

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
    //Clone the request in case we need to use it.
    var clone = await CloneHttpRequestMessageAsync(request);

    //Now do the request
    var response = await base.SendAsync(request, cancellationToken);/*after pressing the next step it steps out and returns me to my login page again*/

    if(response.StatusCode == HttpStatusCode.Unauthorized)
    {
        /*The request result in a 401 Unauthorized. We need to do a LoginAsync.
         which will do the Refresh if appropiate, or ask for credentials if not.*/
        var user = await ServiceLocator.Instance.Resolve<ICloudService>().LoginAsync();

        /*Now retry the request with the cloned request. The only thing we have
         to do is replace the X-ZUMO-AUTH header with the new auth token.*/
        clone.Headers.Remove("X-ZUMO-AUTH");
        clone.Headers.Add("X-ZUMO-AUTH", user.MobileServiceAuthenticationToken);
        response = await base.SendAsync(clone, cancellationToken);
    }

    return response;
}

现在我不是天蓝色的专家,但我不明白为什么它只发生在我的手机而不是桌面上,而且异常并没有告诉我太多,而且除了奇怪的是我一到家就行了它工作正常在家里它成功登录没有问题。 但是这里的工作没有。

我已将本地服务器配置为测试目的,它运行良好,只是登录问题。

0 个答案:

没有答案