1

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

1 Answer 1

2

You might want to use a System.Windows.Forms.WebBrowser to 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 WebClient download the URL file to a file in the computer and use the WebBrowser to Navigate to 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.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks @Vercas. Is there a way to pass login info in System.Windows.Forms.WebBrowser? The page I am trying to access is behind login area. Thanks in advance
Oh yes... Lemme look. I haven't personally used it... ever in my life.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.