How to "share" NTLM authentication through multiple HttpWebRequests?

My C # application gets to a web server that uses NTLM authentication.

I found that every request made to the server (using the new HttpWebRequest) is individually authenticated. In other words, each request results in a 401 response, after which there is an NTLM communication session before I receive the actual response.

eg:.

First GET request:

-> GET xyz 
<- 401 error (WWW-Authenticate:NTLM)

-> GET xyz (Authorization:NTLM base64stuff)
<- 401 error (WWW-Authenticate:NTLM base64stuff)

-> GET xyz (Authorization: base64stuff)
<- 200

Subsequent requests:

-> GET xyz (Authorization:NTLM base64stuff)
<- 401 error (WWW-Authenticate:NTLM) //can this request be avoided?

-> GET xyz (Authorization: base64stuff)
<- 200

(initially, if PreAuthenticate is set to false, subsequent requests looked like the first request, i.e. three basic request requests)

Is there a way to β€œshare” the authentication that is performed on the first request to the server with subsequent HttpWebRequests?

, , , UnsafeAuthenticatedConnectionSharing , true HttpWebRequest, .

, PreAuthenticate true, 401 .

+5
1

, NTLM (, 200), auth, , .

, , , .


: NTLM , , Keep-Alive. . . , NTLM:

http://www.innovation.ch/personal/ronald/ntlm.html

+3

All Articles