My program is working fine after a time period suppose 12:00 pm. Before that it does not work,however the same link works fine anytime in web browser like Firfox or chrome.
using (WebClient wc = new WebClient())
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Ssl3;
wc.Encoding = System.Text.Encoding.UTF8;
wc.Headers.Add(HttpRequestHeader.UserAgent, "AvoidError");
wc.Proxy = null;
string htmlCode = wc.DownloadString(url);
}
I am getting below error: -
*****************************
An exception of type 'System.NullReferenceException' occurred in OptionTest.exe but was not handled in user code
Additional information: Object reference not set to an instance of an object.
*****************************
It shows below error when i catch it :-
System.Net.WebException: The operation has Timed out.
What I have tried:
Also tried,
HttpWebRequest
,WebBrowser Control etc.