How to get HttpClient to pass credentials along with the request?

前端 未结 7 1695
南笙
南笙 2020-11-22 14:52

I have a web application (hosted in IIS) that talks to a Windows service. The Windows service is using the ASP.Net MVC Web API (self-hosted), and so can be communicated with

7条回答
  •  一向
    一向 (楼主)
    2020-11-22 15:29

    You can configure HttpClient to automatically pass credentials like this:

    var myClient = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true });
    

提交回复
热议问题