asp.net-core - 尝试在本地 IIS 中启动时获取 Microsoft.VisualStudio.Services.Common.VssUnauthorizedException:'VS30063
问题描述
我正在运行一个简单的 Web 应用程序,在 VisualStudio.Services.Common 旁边测试 TeamFoundation.Services.Client 并通过 IIS Express 启动应用程序没有问题,但是当我尝试使用本地 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
该类采用运行该工具的人员的凭据,并且不遵守.net core
项目中实际的用户名和密码参数,类似于此票证。所以不能像这样使用 Azure Active Directory Authentication ,也不建议在SOAP 服务中对 REST 服务使用 AAD Authentication。
作为一种解决方法,您可以尝试 Windows 身份验证:
VssConnection connection = new VssConnection(new Uri("http://instanceName:8080/tfs/OrgName/"), new WindowsCredential(new NetworkCredential("xxx", "xxx")));
推荐阅读
- bash - 在bash脚本的目录中交换两个文件
- ionic-framework - 'ckeditor' 不是已知元素 Ionic 4
- python - Stuck understanding ResNet's Identity block and Convolutional blocks
- python - 如何从文本文件中的每一行创建一个字典条目?
- java - 在 ReportPortal、Java Cucumber 中手动设置启动名称
- html - 如何在 css 中设置表单输入的样式?
- html - Flex 1 全宽列然后两列
- azure-data-explorer - 对相似的列字符串值进行分组
- javascript - 如何访问 JavaScript 函数中的当前上下文?
- jsf - 显示来自 String Primefaces 的图像