简体   繁体   中英

Custom URL protocol in Windows to serve HTML content

This question addresses how to register a custom URL protocol to launch an application in response to a link, but I want my handler to serve dynamic content.

Essentially, I'm looking to create a web application that runs on the user's machine instead of a web server. I could set up a localhost , but I want to use a "friendly" URL format that the user can reference elsewhere, eg a hypothetical cats protocol:

cats:fluffy/cheeseburger-consumption-stats

How can I accomplish this? Also, do you see any pitfalls with this approach, such as security warnings from browsers?

I did something similar a few years back, we had a local application and wrote a custom url handler so that we could embed these special links on our web page that when clicked would launch our application and load the file.

The technology is called Asynchronous Pluggable Protocols - http://msdn.microsoft.com/en-us/library/aa767916(v=VS.85).aspx

Here is a quick example explaining the registry settings you need to make and a sample app that handles requests - http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM