Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebBrowserTask fails

The following code works sometimes and most of the time not:

WebBrowserTask wbt = new WebBrowserTask();
        wbt.URL = url;
        wbt.Show();

On both the emulator and a real device (HTC HD7). It will bring up the web browser (IE) but it will not put in the url or navigate to it.

What gives?

like image 922
Rick Rat Avatar asked Nov 23 '10 05:11

Rick Rat


2 Answers

Every time you execute the code, it brings up a new tab. So, if you look @ your tabs, you will see the one with your URL and a bunch of blanks -- which is the bad behavior.

The bad behavior only happens when debugging, tho. So, if you launch with a ctrl+F5 or just run the app from your phone, it should work as you expect.

EDIT: Accentuated the answer - thanks.

like image 119
JP Alioto Avatar answered Oct 10 '22 03:10

JP Alioto


I've only seen it actually fail when debugging, as JP Alioto mentions... and then if you go into the URL bar and come out again, IIRC it loads at that point. (It's been a while since I've done that though, so I could be wrong.) It's very odd. If you're seeing this behaviour when you're not debugging, it would be good to get more details.

One point to note with the WebBrowserTask is that it doesn't handle URLs with "&" in - I use Uri.EscapeDataString(url) before launching the task. It escapes much more than is required, but that has no ill effects that I'm aware of. (It could potentially mean that your "maximum URL length" is effectively shorter than it would be otherwise, I guess.)

like image 20
Jon Skeet Avatar answered Oct 10 '22 05:10

Jon Skeet