显示临时标题-GET请求

时间:2020-03-19 14:13:49

标签: angular ionic-framework

我的离子手机应用程序有问题 当我在浏览器上构建项目时,我的请求可以正确发送每个标头,并且可以进行身份​​验证。但是,如果我使用的是Android设备,则没有任何标头,并且在chrome调试器上有“已显示临时标头”。

debugger chrome

我正在使用HttpClient angular。 你们有任何想法吗? 提前致谢 ! :)

我的离子信息: ionic info

编辑1: 我的身份验证请求如下所示: https://URL/url-login-api?login='+username+'&password='+password

这是我的GET方法的http服务:

public get(pageName, action, params2): Promise<any> {
      let headers = new HttpHeaders();
      let httpParams = new HttpParams();
      for (const item in params2) {
        httpParams = httpParams.append(item, params2[item]);
      }
      return this.http.request(
          'GET',
          this.host + HTTP_CONFIG[pageName][action].URL,
          {
              headers: headers,
              params: httpParams,
              withCredentials: !HTTP_CONFIG[pageName]  [action].PARAMS.withCredentials ? false : true
          }
          ).toPromise().then((resp) => {
           console.log("Response: ", resp)
           return (resp);
          });
     }

这是我如何通过http服务进行身份验证:

this.httpServices.get("AUTH", "LOGIN", {login , password}).then((resp) => {
     const res = resp;
     this.events.publish("logged_in");
     const cookie = JSON.parse(res);
     let token;
     const ln = cookie.length;
     for (let i = 0; i < ln ; i++) {
        if (cookie[i].Key === ".DOTNETNUKE") {
          token = cookie[i].Value;
        }
      }
}

这是后端身份验证方法,他们给了我(我现在还没有任何访问权限)。完全相同的方法在浏览器模式下起作用(发送了Set-Cookie标头等):

if (loginStatus != UserLoginStatus.LOGIN_USERNOTAPPROVED &&
                    loginStatus != UserLoginStatus.LOGIN_FAILURE)
                {
                    HttpContext.Current.Response.AppendHeader("Access-Control-Allow-Origin", "*");
                    HttpContext.Current.Response.AppendHeader("content-type", "application/javascript");
                    var coll = new List<KeyValuePair<string, string>>();
                    foreach (string cookie in HttpContext.Current.Request.Cookies)
                    {
                        var httpCookie = HttpContext.Current.Request.Cookies[cookie];
                        if (httpCookie != null)
                            coll.Add(new KeyValuePair<string, string>(cookie,
                                string.Join(",", httpCookie.Value)));
                    }
                    return Json.Serialize(coll);
                }

0 个答案:

没有答案
相关问题