WebClient DownloadStringAsync Method returns null

141 Views Asked by At

I am using this C# code in LINQPad 6 (Free Edition) to download data from a webpage

void Main()
{

string a = "https://www1.nseindia.com/live_market/dynaContent/live_watch/option_chain/optionKeys.jsp";

WebClient w = new WebClient();

w.DownloadStringAsync(new Uri(a));

w.DownloadStringCompleted += (s,e) => { 
        string t = (string)e.Result;
        Console.WriteLine (t);
        };   

}

I am always getting the WebException - An error occurred while sending the request. The response ended prematurely. enter image description here

Can anyone please kindly point out my mistake. Awaiting your reply. Thank you.

0

There are 0 best solutions below