Skip to main content

Creating Custom Protocol Links

Custom Protocol Links

We can create custom protocol links that can carry out operations as per the configurations
For example: <a href="mailto:as@b.c">

Similar to the mailto protocol we can create our own protocol. In my case I created one that would launch an application when this link is clicked. I had to start a project in my solution based on certain conditions. So I created this custom protocol that would start the project based on the requirements.

Create an entry in the registry as follows 



Add a new string value to the command folder with the path to the .exe file that needs to be launched

ex: "C:\mine\sample.exe" "%1". The %1 denotes that we will be passing parameters to the main method . The parameters will be received inside the string[] args in the main Method of the program.

Creating a custom MIME TYPE


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.msg]
    @="msg_file"

[HKEY_CLASSES_ROOT\msg_file]
    @="MSG"

[HKEY_CLASSES_ROOT\msg_file\shell]

[HKEY_CLASSES_ROOT\msg_file\shell\open]

[HKEY_CLASSES_ROOT\msg_file\shell\open\command]
    @="\"C:\\AtomHandler\\handle.exe\" %1"

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/msg]
    "Extension"=".msg"


Comments

Popular posts from this blog

App Role assignment to service principal --

 Using Ms Graph Rest API's Permissions One of the following permissions is required to call this API. To learn more, including how to choose permissions, see  Permissions . Permission type Permissions (from least to most privileged) Delegated (work or school account) AppRoleAssignment.ReadWrite.All and Application.Read.All, AppRoleAssignment.ReadWrite.All and Directory.Read.All, Application.ReadWrite.All, Directory.ReadWrite.All Delegated (personal Microsoft account) Not supported. Application AppRoleAssignment.ReadWrite.All and Application.Read.All, AppRoleAssignment.ReadWrite.All and Directory.Read.All, Application.ReadWrite.All, Directory.ReadWrite.All Create 2 app registrations. App role owner will contain the app role that will be assigned to a service principal. The  reader role in approleowner will be added to the approlesubscriber Setup postman to use the Oauth auth flow to get a token for MS Graph. ClientId:   Application (client) ID for approlesubscrib...

ASp.net core 3.1 identity

It is just an extension to cookie authentication. We get a UI, Tables, helper classes, two factor authentication etc. Even EF and its database constructs. So instead of writing code for all of this we can just use these in built features. Extending Default Identity Classes Add a class that inherits from    public class AppUser : IdentityUser     {         public string Behavior { get; set; }     } Also change the user type in login partial.cs under shared folder Then add migrations and update db using migrations. We can customize further.  services.AddDefaultIdentity<AppUser>(options =>              {                 options.SignIn.RequireConfirmedAccount = true;                 options.Password.RequireDigit = false;           ...

Get user groups

 string[] scopes = new string[] { "https://graph.microsoft.com/.default" };             string clientId = "";             string tenantId = "";             string secret = "";                        var options = new TokenCredentialOptions             {                 AuthorityHost = AzureAuthorityHosts.AzurePublicCloud             };             // https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential             try             {                 var clientSecretCredential = new ClientSecretCredential(                        ...