Search Posts

Access windows Authenticated Web API through Angular 2 without login prompt

I have already developed front-end application in Angular2 and back-end in ASP.net web APIs. I had used Windows authentication as enabled because I want to detect requesting user. Both applications are hosted in IIS server(Windows Server 2012).
When I load angular app it load login prompt and when give correct user credentials data loading happen correctly.
But I want to know a way to load them without login prompt, authenticate automatically.

This is the way I detect request user in web APIs.

string user = HttpContext.Current.Request.ServerVariables["LOGON_USER"]; //Get the current user...
userID = user.Split('')[1]; 

This is a sample TS script send request to Windows Authenticated Web APIs from Angular Services.

getPersonalInfo(): Observable<IPersonalInfo> {
        return this._http.get(localStorage.getItem('WebApiURL') +"api/PersonalInfo/" , { withCredentials: true })
            .map((response: Response) => <IPersonalInfo>response.json())
            .catch(this.handleError);
    }

When restart the browser this login ask every time.
enter image description here

I want to access them with out this login…

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *