This is the login panel

How to Create an Add-on and Add Visual Studio C# Code

You add code to Add-ons that populate your application. An Add-on is a record that manages the features of an application's functionality. For example, an add-on may include a call to .NET code in a .NET assembly installed on the server.

NOTE: These instructions assume you have built a demo site to run your add-on.

How to create an endpoint Add-on that returns "Hello world!" when hit from the browser:

  1. Log into the administration website (Located at http://{yourAppName}/admin by default). 
  2. Locate the Navigator window on the left.
  3. Expand the "Manage Add-ons" directory.
  4. Scroll to the bottom and expand the "Advanced" directory.
  5. Click on "Add-on Collections".
  6. In the new "Add-on Collections" window, click on "Add" at the top.
  7. Name your new Collection "DemoCollection". This creates a folder location on the server where your .NET code will be stored.
  8. Click "OK".
  9. Click on "Add-ons" located above "Add-on Collections" in the same "Advanced" directory.
  10. In the new "Add-ons" window, click on "Add" at the top.
  11. Name the new Add-on "HelloWorld".
  12. Add the new Add-on to "DemoCollection" by clicking on the "None" box and locating your Collection.
  13. Click on the "Placements" tab.
  14. Locate and enable the "Is Remote Method" setting. This allows the Add-on to be executed by using "HelloWorld" as an endpoint to your application's domain.
  15. Click on the "Content" tab and enter "Hello world!" into the "Content" box.
  16. Click "OK".
  17. To test the Add-on with your browser, hit the same domain as the administration site, but with your /HelloWorld endpoint. You will see "Hello World".

How to create  a "Hello World!" .NET C# program with the proper Contensive format:

  1. Open Visual Studio.
  2. Create a new C# .NET Framework Class Library (ensure that the project is .NET Framework because we are interested in the .dll files)
    and name the project "HelloWorldAddon".
  3. Delete the default "Class1.cs" class if present.
  4. Add a new class to the library named "HelloWorldClass".
  5. Right click on your project in the solution explorer and click "Manage NuGet Packages for Solution."
  6. Click on the "Browse" tab; search for and install the "Contensive.CPBaseClass" package.
  7. Go back to your "HelloWorldClass" and paste the following sample code.
  8. Build the solution.

using Contensive.BaseClasses;

namespace HelloWorldAddon {
    public class HelloWorldClass : AddonBaseClass 
    {
        public override object Execute(CPBaseClass cp) 
        {
            return "Hello World from .NET";
        }
    }
}

How to edit your Add-on so it displays the JSON data returned by your .NET C# program:

  1. Right click on your solution in Visual Studio and click "Open Folder in File Explorer".
  2. Navigate to \HelloWorldAddon\bin\Debug and copy "HelloWorldAddon.dll". The .dll files are referred to as "Assemblies".
  3. Now we must find the local "DemoCollection" directory. In the drive that you chose to store your Web Application, navigate to \inetpub\{yourAppName}\private\addons\DemoCollection_{guid}\most-recent-folder and paste the copied Assembly inside this directory.
  4. Back to your website, find your "HelloWorld" Add-on in the navigator and go to the edit menu.
  5. Click on the "Code" tab. 
  6. In the "DotNet Namespace.Class" field, enter "HelloWorldAddon.HelloWorldClass".
  7. Click "OK".
  8. To test, hit your /HelloWorld endpoint again and see "Hello World from .NET".

NOTE: If "Hello World from .NET" does not appear when you hit the endpoint Add-on, the list of Collections may not have updated automatically to contain your "DemoCollection". To manually update the list, navigate to \inetpub\{yourAppName}\private\addons and delete the "Collections.xml" file. Now try to hit the endpoint Add-on again. If the text still does not appear, check that you completed all the steps listed for creating the Add-on at the top of this page. Contact support@contensive.com if all else fails.

Posted By Jay Kidwell | 4/13/2019 10:51:25 PM
 

Search

Archives

Subscribe By RSS

Default Blog Feed