0 votes
ago in Education by (1.7m points)
I need to check if url exists and can be reached. In order to do it I send Get request and handle the status:

var httpClient = new HttpClient();

var response = httpClient.GetAsync(new Uri(pageUrl));

isPageAccessible = response.Result.StatusCode == HttpStatusCode.OK;

However, the server uses NTLM for authentication. As I found it here, there are several steps (requests) before I get success OK status. For the first request I get 401 Unauthorized status and can't go to further steps.

All in all, how can I check url on the server with NTML upon completion of all requests?

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
ago by (1.7m points)
If you are accessing an authenticated server, you should provide credentials. Credentials of running process for NTLM can be provided with HttpClient as below:

var handler = new HttpClientHandler {

                      Credentials = System.Net.CredentialCache.DefaultCredentials


var httpClient = new HttpClient(handler);

var response = httpClient.GetAsync(new Uri(pageUrl));