'HTTPClent error An invalid request URI was provided

I am trying to get the content from a web page using this code :

HttpClient http = new HttpClient();
var response = await http.GetByteArrayAsync("www.nsfund.ir/news?p_p_id=56_INSTANCE_tVzMoLp4zfGh&_56_INSTANCE_tVzMoLp4zfGh_mode=news&_56_INSTANCE_tVzMoLp4zfGh_newsId=3135919&p_p_state=maximized");
String source = Encoding.GetEncoding("utf-8").GetString(response, 0, response.Length - 1);
source = WebUtility.HtmlDecode(source);
HtmlDocument resultat = new HtmlDocument();
resultat.LoadHtml(source);

But I get this error :

An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.



Solution 1:[1]

You simply need to specify the full URL ( including the protocol) like this:

var response = await http.GetByteArrayAsync("http://www.nsfund.ir/news?p_....

Solution 2:[2]

An absolute URI follows the protocol://server/path?query#hash convention. As you did not specify a protocol, specifically http:// or https:// in your case, the URL is not absolute and thus cannot be resolved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yacoub Massad
Solution 2 Niels Keurentjes