.net core as service calling web api RRS feed

  • Question

  • I have a .net core service listening for http requests. I want it to to call a web api using a windows credential. I have specified in the http client to use NTLM and passed in a network credentital 


     services.AddHttpClient("webApi").ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler
                    Credentials = new CredentialCache {
                            new Uri("http://localhost:61268/api/messages"), "NTLM", new NetworkCredential("xxx", "yyyy", "zzzz")


         in a service where I have injected the IHttpClientFactory  

          var client = _clientFactory.CreateClient("webApi");
          var httpResponse = client.PostAsync(uri, httpContent);

    This yields a 401. The webapi is running on my local machine in IISExpress and has anonymous turned off and it has Windows Authentication turned on. 

    Is it possible to call the web api using an account other than the one under which the service is running?

    Friday, February 8, 2019 11:20 PM

All replies

  • Hi Steve Kollmorgen,

    Since your question is more related to web API, you could post a new thread in ASP.NET forum for suitable support.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework, including Managed Extensibility Framework (MEF), Charting Controls, CardSpace, Windows Identity Foundation (WIF), Point of Sale (POS), Transactions.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 11, 2019 7:13 AM