Search code examples
c#wpfuser-interfaceurl-schemeentry-point

What's the Entry Point for a URL Scheme in C#?


I registered an URI scheme for my C# WPF GUI application by following the official guide: https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)

When I click on a link it will open up my app or bring it in the foreground. But where do I get the URL the app was started with? The guide uses the main method. But my GUI app has no main method.

Whats the method I need to implement to get the clicked URL?


Solution

  • In your App.xaml.cs, override the OnStartup method or subscribe to the Application.Startup event. The StartupEventArgs has an Args property which gives you your command-line arguments.