I am trying to access a website via webclient in .net but I am getting an error message saying this:
“Microsoft Online Services requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.”
Here is the code I am using to access the website:
string url = "myUrl";
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1");
client.Credentials = new NetworkCredential("username", "Password");
string lines = client.DownloadString(url);
Any help is appreciated. Should I change the user agent or try something else?
Thanks in advance, Laziale
You might want to use a
System.Windows.Forms.WebBrowserto parse the Javascript.A web client only attempts downloads the file.
Javascripts are not processed on the server… They are processed on the client.
So, with your
WebClientdownload the URL file to a file in the computer and use theWebBrowsertoNavigateto the downloaded file.It will parse the Javascripts and other stuff and after finished (there must be an event for that) you can retrieve the (parsed) content and work with it.
That whole “you must enable Javascript thing” is hidden by a Javascript.
It’s not the server the one who detects it.