ASP .NET Web API中的Windows身份验证,角度为6 [英] Windows authentication in ASP .NET web API with angular 6

查看:90
本文介绍了ASP .NET Web API中的Windows身份验证,角度为6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络API中启用了Windows身份验证。我的前端应用程序是由Angular 6开发的。当我调用API时,它在控制台中显示未经授权的问题。但是凭证没有弹出窗口。



请帮忙。如何配置角度以便凭证弹出来。



我尝试过:



I have enabled windows authentication in web API. My Frontend application is developed by Angular 6. When I call API, its showing unauthorized issue in the console. But no popup comes for the credential.

Please help. How to configure in angular so that credential popup will come.

What I have tried:

get(commandID, moduleID, data) {
    const actionURL = AppUrlConfig.getUrl(commandID);
    return this.http.get(environment.baseApi + actionURL.url, 
     this.comServ.GetHeaderValue())

  }

推荐答案

当你调用web api时,你必须传递 {withCredentials:true} 。因此弹出窗口将出示凭证

When you call the web api, you have to pass { withCredentials: true}. So that popup will come for credential
get(commandID, moduleID, data) {
    const actionURL = AppUrlConfig.getUrl(commandID);
    return this.http.get(environment.baseApi + actionURL.url, 
     { withCredentials: true})
    .pipe(catchError((error: Response) =>{      
      this.router.navigate(['/errorpage']);
      return throwError(error);       
    }));

  }


这篇关于ASP .NET Web API中的Windows身份验证,角度为6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆