WebBrowserTask Error

The following code works sometimes and most of the time:

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

Both on the emulator and on a real device (HTC HD7). This will lead to the creation of a web browser (IE), but it will not embed or navigate to the URL.

What gives?

+6
browser windows-phone windows-phone-7 task
source share
2 answers

Each time you execute the code, a new tab appears. So, if you look @ your tabs, you will see someone who has a URL and a bunch of spaces - this is bad behavior.

Bad behavior only occurs during debugging, because if you launch ctrl + F5 or just launch the application from your phone, it should work as you expect.

EDIT: Emphasized the answer - thanks.

+7
source share

I just saw that it really fails when debugging, as JP Alioto mentions ... and then if you go into the URL bar and exit again, IIRC loads at that moment. (It has been some time since I did this, so I could be wrong.) This is very strange. If you see this behavior when you are not debugging, it would be nice to get more details.

One point to note with WebBrowserTask is that it does not process URLs with &, I used Uri.EscapeDataString(url) before starting the task. This eludes much more than is required, but it does not have any negative consequences that I know of. (This could potentially mean that your maximum URL length will be significantly shorter than it would otherwise, I think.)

+6
source share

All Articles