Search code examples
c#html.netgoogle-chrome-extension

Open a .net app with parameters using google chrome browser extension


I made a dotnet app that will take a link and convert it. I wanna know how I can make a google chrome extension that will open the app with parameters.

This is Path: "D:\Code\C#\GoogleClasses\bin\Debug\netcoreapp3.1\GoogleClasses.exe"

These are the parameters: --convert https://stackoverflow.com/questions/ask

Please any help will be appreciated


Solution

  • If I understood your requirements correctly. Here is the way

    1. You can't directly call an exe from Chrome or other browsers. Even with an extension directly.

    However you can do it with a bit of work. Use Chrome's NativeMessaging API .Native applications that support this feature must register a native messaging host that knows how to communicate with the extension. NativeMessaging API: https://developer.chrome.com/docs/apps/nativeMessaging/

    1. If you don't know how to create a Chrome extension, You can easily create a quick readymade extension (which you can customize anytime later) from here: https://extensionizr.com/ On the extension you can call the exe based on your requirements like on a specific range or URLs or whatever

    2. Then just add the extension to chrome and enable it. This will invoke the exe with the parameters and you can produce the output using C#