C# 具有NetworkCredential的HttpClient为.net framework返回.net核心200的401

C# 具有NetworkCredential的HttpClient为.net framework返回.net核心200的401,c#,.net,.net-core,C#,.net,.net Core,我有以下代码: using System.Net; using System.Net.Http; class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("user", "password", "domain"); using (HttpClientH

我有以下代码:

using System.Net;
using System.Net.Http;
    class Program
    {
        static void Main(string[] args)
        {
            NetworkCredential credential = new NetworkCredential("user", "password", "domain");

            using (HttpClientHandler handler = new HttpClientHandler() { Credentials = credential })
            {
                using (HttpClient client = new HttpClient(handler))
                {
                    string authUrl = "https://example.net";
                    var authresponse = client.GetAsync(authUrl).Result;
                }
            }
        }
    }
(url和凭据是匿名的)

在.NETFramework控制台中,我得到响应200

在.NETCore1.1中,我得到了401响应

我想这是.NETCore和.NETFramework在实现上的不同。有什么办法解决这个问题吗?或者在哪里报告此错误/功能


谢谢

最后我这样解决了它:

NetworkCredential credential = new NetworkCredential("user", "password", "domain");

using (WinHttpHandler handler = new WinHttpHandler() { ServerCredentials = credential})
{
    using (HttpClient client = new HttpClient(handler))
    {
        string authUrl = "https://example.net";
        var authresponse = client.GetAsync(authUrl).Result;
    }
}

我相信您应该能够使用CredentialCache明确指定您正在使用NTML方案。显然,在最近的.netcore版本中,这是不必要的


您调试过代码吗?在每一个环境中都进行了检查?“那里可能有一些片段没有被填充。@krillgar是的,我有,这些类是不同的,所以很难区分。我也检查了Fiddler中的请求。没什么明显的。。