Ray Booysen
Ray Booysen

Reputation: 30031

How do I stop 401 responses from TFS 2008

Whenever a web request is made by Visual Studio to TFS, Fiddler will show a 401 Unauthorized error. Visual Studio will then try again with a proper Authorization Negotiate header in place with which TFS will respond with the proper data and a 200 status code.

How can I get the correct headers to be sent the first time to stop the 401?

Upvotes: 0

Views: 1399

Answers (3)

Brady Moritz
Brady Moritz

Reputation: 8903

This is how it's always done - request, get the 401 back, then send the authorization. It's part of the authentication protocol for http.

Upvotes: 0

Martin Woodward
Martin Woodward

Reputation: 11770

This is how the process of Windows Integrated Authentication (NTLM) works. NTLM is a connection based authentication mechanism and actually involves 3 calls to establish the authenticated session.

The TFS API then goes to extra-ordinary lengths to make sure that this handshake is done in the most efficient way possible. It will keep the authenticated connection open for a period of time to avoid this hand-shake where possible. It will also do the initial authentication using a HTTP payload with minimal content and then send the real message if the message you were going to send is over a certain length. It does a bunch of other tricks as well to optimise the connection to TFS.

Basically, I would just leave it alone as it works well.

Upvotes: 5

Chris Simpson
Chris Simpson

Reputation: 7990

You will see that a web browser also does this when communicating with a web site. It will always try to give away the minimum amount of detail with the first call. If this fails, it will reveal a little more about you.

This is by design and for a very good reason.

Upvotes: 0

Related Questions