我的后端是在IIS下运行的ASPNet WebApi2,使用Windows身份验证
。
我有两个客户端:
WinForms: Passing the credentials is simple. I do the following:
var credentialCache = new CredentialCache(); credentialCache.Add(new Uri(uri.GetLeftPart(UriPartial.Authority)), "NTLM", credentials); WebRequestHandler handler = new WebRequestHandler() { AuthenticationLevel = AuthenticationLevel.MutualAuthRequested, Credentials = credentialCache, PreAuthenticate = true, UseDefaultCredentials = false }; client = new HttpClient(handler, true) { BaseAddress = uri, };
Angular: As the end-user will access the WebApi backend using the Angular app from non-Windows systems, how can I pass his/her windows credentials? (I have a login screen where the user must enter his domain/name and password).
我希望能够通过代码传递用户凭据。类似于typed_rest-client这样的方式。不幸的是,这个库会导致构建错误,无法使用。