I'm searching for a way to register a custom protocol for Windows Phone 8. I tried to register a custom protocol with WebRequest.RegisterPrefix("xxx://", this)
but this will not work for the WebBrowser
control. Since our protocol scheme is no valid uri the app will just crash if it try to navigate (via location.url='xxx://this-is-no-valid-uri').
I hope anyone can spread light into the darkness ;)
EDIT: Here is my test project. I think this is a major bug because you can force every app to crash with just a simple JavaScript statement.
I finally got a Solution for my Problem, you need to register a own UriParser.
My UriParser:
public class MyUriParser : UriParser
{
public MyUriParser()
{
}
protected override string GetComponents(Uri uri, UriComponents components, UriFormat format)
{
return "";
}
protected override bool IsWellFormedOriginalString(Uri uri)
{
return true;
}
protected override void InitializeAndValidate(Uri uri, out UriFormatException parsingError)
{
parsingError = null;
}
protected override bool IsBaseOf(Uri baseUri, Uri relativeUri)
{
return false;
}
protected override string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError)
{
parsingError = null;
return "";
}
}
Registered via:
if (!UriParser.IsKnownScheme(SCHEMENAME_0))
UriParser.Register(new MyUriParser(), SCHEMENAME_0, 80);