[英]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.