正在尝试在本地 IIS 中启动时获取 Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: 'VS30063

Getting Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: 'VS30063 when trying to lauch in local IIS

im 运行 一个简单的 Web 应用程序测试 TeamFoundation.Services.Client 和 VisualStudio.Services.Common 并通过 IIS Express 启动应用程序没有问题,但是当我尝试使用 Local 执行相同操作时IIS 我收到这个错误:

Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: 'VS30063: You are not authorized to access http://mytfs:8080.

This exception was originally thrown at this call stack:
    Microsoft.VisualStudio.Services.Common.VssHttpMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
    Microsoft.VisualStudio.Services.Common.VssHttpRetryMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
    System.Net.Http.HttpClient.FinishSendAsyncBuffered(System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>, System.Net.Http.HttpRequestMessage, System.Threading.CancellationTokenSource, bool)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    ...
    [Call Stack Truncated]

我不明白是什么问题。

这是我尝试启动它的调试配置文件:

这是我收到错误的代码:

internal const string vstsCollectioUrl = "http://myTFS:8080/tfs/MyCollection"; 

//Prompt user for credential
VssConnection connection = new VssConnection(new Uri(vstsCollectioUrl), new VssAadCredential("{user}", "{password}"));

//create http client and query for resutls
WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();

VssAadCredential class 默认情况下使用人员 运行 工具的凭据并且不遵守 .net core 项目中实际的用户名和密码参数,类似至 this ticket. So you can't use Azure Active Directory Authentication like this, and it's not recommended to use AAD Authentication for REST services in SOAP service.

作为解决方法,您可以尝试 windows 身份验证:

VssConnection connection = new VssConnection(new Uri("http://instanceName:8080/tfs/OrgName/"), new WindowsCredential(new NetworkCredential("xxx", "xxx")));