Hello,
Welcome to Microsoft Q&A!
Please refer to this document for handling URLs with apps: Enable apps for websites using app URI handlers.
In the sample code, uap5 namespace is not required.
This is a simple code example:
<Package
...
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
IgnorableNamespaces="uap mp uap3">
<Applications>
<Application ... >
...
<Extensions>
<uap3:Extension Category="windows.appUriHandler">
<uap3:AppUriHandler>
<uap3:Host Name="msn.com" />
</uap3:AppUriHandler>
</uap3:Extension>
</Extensions>
</Application>
</Applications>
</Package>
In addition, you also need to add the handling of OnActivated life cycle events in App.xaml.cs, in which to respond to the launch through Uri
protected override void OnActivated(IActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
...
}
// Check ActivationKind, Parse URI, and Navigate user to content
Type deepLinkPageType = typeof(MainPage);
if (e.Kind == ActivationKind.Protocol)
{
var protocolArgs = (ProtocolActivatedEventArgs)e;
switch (protocolArgs.Uri.AbsolutePath)
{
case "/":
break;
case "/index.html":
break;
case "/sports.html":
deepLinkPageType = typeof(SportsPage);
break;
case "/technology.html":
deepLinkPageType = typeof(TechnologyPage);
break;
case "/business.html":
deepLinkPageType = typeof(BusinessPage);
break;
case "/science.html":
deepLinkPageType = typeof(SciencePage);
break;
}
}
if (rootFrame.Content == null)
{
// Default navigation
rootFrame.Navigate(deepLinkPageType, e);
}
// Ensure the current window is active
Window.Current.Activate();
}
After that, you can press the Win+R key combination and enter the URL to check whether it takes effect.
Thanks.