#

Angular Error TypeError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': String contains non ISO-8859-1 code point

 

1.  e: TypeError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': String contains non ISO-8859-1 code point. at http://localhost:4200/vendor.js:19785:49 at http://localhost:4200/vendor.js:18257:60 at Array.forEach (<anonymous>) at HttpHeaders.forEach (http://localhost:4200/vendor.js:18257:45) at Observable._subscribe (http://localhost:4200/vendor.js:19785:19) at Observable._trySubscribe (http://localhost:4200/vendor.js:5390:19) at http://localhost:4200/vendor.js:5384:113 at errorContext (http://localhost:4200/vendor.js:8002:5) at Observable.subscribe (http://localhost:4200/vendor.js:5379:69) at doInnerSub (http://localhost:4200/vendor.js:6885:95)

1.  message: "Failed to execute 'setRequestHeader' on 'XMLHttpRequest': String contains non ISO-8859-1 code point."

2.  stack: "TypeError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': String co

 

 

Lösung:
wenn man Frontend und Backend auf dem gleichen Debugger-Browser laufen lässt, dann kommt der Fehler.

Man muss das Frontend im Standard-Browswer Chrome oder Edge starten.

Das ASP.Net MVC Backend wird normalerweise in einer reduzierten Debug-Variante gestartet

Ein Bild, das Text, Screenshot, drinnen, schwarz enthält.
Automatisch generierte Beschreibung

 

In Angular:
beim Senden von Daten im Angular Frontend an ein C# Asp.Net Backend

    public register(username:string, email:string, password:string) {

    //*try to /register with email password and get token as result.

    //if token is ok, then true else false

    return this.http.post<any>(url_Api_Auth + "/register",{Username:username,Email:email,Password:password})

    //#test: return this.http.post<any>(url_Api_Auth + "/register",{username:'u',email:'e',password:'p'})

    .subscribe(

      {

        next: (response_username_token:any ) => {

          //*store token in local storage

          var token=response_username_token.token;

          var username=response_username_token.username;

 

          this.cookieService.set('t', token,365);

          this.token=token;        

          localStorage.setItem('u',JSON.stringify(username))

          this.userSubject.next(username);

          console.log("register ok");

          this.router.navigate(['/home']);

          return true;

        }

        ,error: (e) => {

          console.log("/register.error:" + e.message);

          alert(e.message);

          return false;

        }

        ,complete: () => console.log('register complete')

      });

    //console.log("webrequest=" + webrequest);

    //if (this.token!="") return true; else return false;    

  }

 

 

Mobile

.

123movies