简体   繁体   English

如何在asp.net Web表单中通过身份验证(团队基础服务器)连接到TFS?

[英]how to connect to TFS by authentication (Team foundation server) in your asp.net web form?

I'm trying to create a page where I will be getting all the Workitem in the tfs. 我正在尝试创建一个页面,我将在其中获取所有的Workitem。 But I don't know how to Connect to TFS. 但是我不知道如何连接到TFS。 what reference I need to add currently my code is ( which I get from internet ). 当前我需要添加的代码是什么参考(我从互联网获得)。

NetworkCredential credential = new NetworkCredential("username", "password");  
BasicAuthCredential basicCred = new BasicAuthCredential(credential);  

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(  
new Uri("https://project.visualstudio.com/DefaultCollection"),  
basicCred);  

tpc.Authenticate(); 

错误代码 在此处输入图片说明

First of all, add this library using nuget: 首先,使用nuget添加该库:

Microsoft.TeamFoundationServer.ExtendedClient

Also you need this namespace, so you should add it to the page: 另外,您需要此名称空间,因此应将其添加到页面中:

Microsoft.TeamFoundation.Client

Then you can connect to TFS with following code: 然后,您可以使用以下代码连接到TFS:

var collectionUri = new Uri("https://project.visualstudio.com/DefaultCollection");

var credential = new NetworkCredential("username", "password");
var teamProjectCollection = new TfsTeamProjectCollection(collectionUri, credential);
teamProjectCollection.EnsureAuthenticated();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Team Foundation ASP.NET(如果条件) - Team Foundation ASP.NET if Condition 如何连接到SQL Server并通过ASP.NET Web窗体查看数据库中的数据? - How can I connect to SQL Server and view the data in the database through ASP.NET Web Form? 如何将Web表单与在asp.net中的另一台计算机上运行的sql server连接 - how to connect web form with sql server running on an other computer in asp.net 用于IIS的C#ASP.net应用程序的Team Foundation Server构建过程 - Team foundation server build process for a C# ASP.net application to IIS 如何在使用C#作为服务器代码的ASP.NET Web应用程序中使用WF(Windows Workflow Foundation) - How to use WF (Windows Workflow Foundation) in a ASP.NET web application using C# as Server Code 如何在 Visual Studio Asp.net 项目中为不同的团队成员设置不同的 web 服务器配置? - How to set up different web server config for different team members in Visual Studio Asp.net Project? 如何在asp.net中设置表单身份验证 - how to set Form authentication in asp.net 使用 Identity Server 对 ASP.NET Web App 和 .NET 进行身份验证 6 - Using Identity Server for Authentication with ASP.NET Web App and .NET 6 ASP.NET表单身份验证在本地主机服务器上进行身份验证,但不在Web服务器上进行身份验证 - ASP.NET Forms Authentication authenticates in localhost server, but not on the web server Windows身份验证后ASP.NET Web窗体未加载样式表 - ASP.NET Web Form not loading stylesheets after windows authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM