Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top