locked
Opening Invalid Uris in IE in Windows Phone 8.1

    Question

  • I have an app in which part of the data entered and stored for each item by the user is a Uri. When the user views their items, I want them to be able to click the Uri to open it in IE. However, I do not want to force them to enter a valid Uri, since it is not a mandatory field and is just for their convenience. I want the Uri (unless it is blank, meaning they did not enter one) to open in IE even if it is invalid. However, if the Uri is invalid I get a System.UriFormatException, which prevents me from creating a Uri to assign to my HyperLinkButton.NavigateUri property. Is there any way to manually open IE and go to a specified Uri without actually creating a Uri object? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Friday, December 12, 2014 1:34 AM

Answers

  • You need to provide a validly formatted URI.
    Friday, December 12, 2014 2:47 AM
    Owner

All replies

  • No. Apps cannot directly launch other apps. To launch a Uri you need to create a Uri object and then call Launcher.LaunchUriAsync and it will launch in the user's default browser.

    You can handle the UriFormatException to catch invalid Uri formats. Such Uris wouldn't open appropriately in a browser anyway. If you want to launch a search you could rewrite the Uri to call a search engine (i.e. http://www.bing.com/search?q=invalid%20Uri%20goes%20here )

    --Rob

    Friday, December 12, 2014 2:04 AM
    Owner
  • Does that mean that if my user entered an invalid (or mistyped) their Uri I can't give them a link to open it in the browser?

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Friday, December 12, 2014 2:20 AM
  • You need to provide a validly formatted URI.
    Friday, December 12, 2014 2:47 AM
    Owner