
目标是使用windows身份验证.我尝试了如下:
var handler = new httpclienthandler{ UseDefaultCredentials = true,};this.InitializehttpClIEnt(handler); 这不起作用,我得到:
System.Net.http.httpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The Remote Server returned an error: (401) Unauthorized. ---> System.ComponentModel.Win32Exception: The target principal name is incorrect
当我使用基本身份验证时,它工作.
this.Credentials = new BasicAuthenticationCredentials{ Username = Configuration.User,Password = Configuration.Password}; ServiceClIEnt的这个设置是在构造函数中完成的
MyClIEnt : Microsoft.Rest.ServiceClIEnt
我需要向客户端添加什么才能使windows身份验证正常工作?
编辑:
看起来问题出在服务器端. IIS中的设置.
客户端将按预期工作.
解决方法 这基本上重申OP中已经涵盖的内容和@Anders,我的首选语法…var windowsAuthHandler = new httpclienthandler { UseDefaultCredentials = true }; var webAPIUri = new System.Uri("https://localhost:8080"); var apiclient = new MyautoRestClIEnt(webAPIUri,windowsAuthHandler); 如果你正在浏览,OP似乎表明这不起作用,确实如此.但是,正如OP后来所述,请确保从IIS开始,以确保它配置正确
总结以上是内存溢出为你收集整理的c# – 如何在Microsoft.Rest.ServiceClient中使用Windows身份验证全部内容,希望文章能够帮你解决c# – 如何在Microsoft.Rest.ServiceClient中使用Windows身份验证所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)