0
votes

We are trying to make a parsing over an intranet site. The html response is Ok.

The problem is to load the string html in the class HtmlDocument.

We are getting a 401 Unauthorized status. What I don't understand is why this status if there is no http request when loading from string.

Our code is as follows:

..................

           WebResp = (HttpWebResponse)WebReq.GetResponse();
            Stream answer = WebResp.GetResponseStream();
            StreamReader _answer = new StreamReader(answer);
            string responseText = _answer.ReadToEnd();

 HtmlAgilityPack.HtmlDocument resultat = new 
                    HtmlAgilityPack.HtmlDocument();
             resultat.LoadHtml(responseText);

Any help?

1

1 Answers

0
votes

What do you mean by

there is no http request

There is a WebReq variable in your code and it will connect to the server to get the response. In term of 401 error, if it's intranet site then probably you can use one of those solution from this link Passing NetworkCredential to HttpWebRequest in C# from ASP.Net Page