Page Interaction event handlers
This following information describes how to develop your own custom Page Interaction event handlers by providing general guidelines and code samples.
This page contains the following information:
- Guidelines for Page Interaction event handlers
- Code sample for a Page Interaction event handler
- Helper method for custom page URLs
See the following related pages:
Guidelines for Page Interaction event handlers
Use these guidelines when developing Page Interaction event handlers:
- Create a new class in Visual Studio.
Note: You can also use a template to create this event handler type. For more information, see Visual Studio templates.
- Add NuGet packages - ensure your Visual Studio project has installed the relevant NuGet packages, including at a minimum the Relativity.EventHandler and Relativity.Api packages.
- Add a GUID for the event handler - set the System.Runtime.InteropServices.Guid to the GUID identifying your event handler. Use the GUID generator in Visual Studio.
- Set the CustomAttributes.Description attribute - provide a description that you want to appear in the Relativity UI for the event handler.
- Inherit from the PageInteractionEventHandler class – extend the base class for this type of event handler
- Upload your event handler assembly to Relativity - use the Resource Files tab to upload your compiled .dll file to Relativity. See Add event handlers to applications.
- Optionally use event handlers to construct HTTP responses - event handlers can't access the request header, cookies, or session information using the HTTPContext object, although they can assisted in constructing an HTTP response.
Code sample for a Page Interaction event handler
Review the following code sample for a Page Interaction event handler.
Helper method for custom page URLs
The following code sample illustrates how to use a helper method to obtain the string path of the custom pages for an application on the web server. The GetRelativePathToCustomPages() method is available on the IUrlHelper interface in the Relativity.API namespace. For more information, see Use API helper classes and Simplify custom page URLs.
Note: You may want to reference the RelativityInstanceURL instance setting if you are creating external links for users to access your application. Your Relativity admin can configure this value for your environment. See Instance setting table and Instance settings' descriptions on the Relativity Server 2022 Documentation site.