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:
- Log into the administration website (Located at http://{yourAppName}/admin by default).
- Locate the Navigator window on the left.
- Expand the "Manage Add-ons" directory.
- Scroll to the bottom and expand the "Advanced" directory.
- Click on "Add-on Collections".
- In the new "Add-on Collections" window, click on "Add" at the top.
- Name your new Collection "DemoCollection". This creates a folder location on the server where your .NET code will be stored.
- Click "OK".
- Click on "Add-ons" located above "Add-on Collections" in the same "Advanced" directory.
- In the new "Add-ons" window, click on "Add" at the top.
- Name the new Add-on "HelloWorld".
- Add the new Add-on to "DemoCollection" by clicking on the "None" box and locating your Collection.
- Click on the "Placements" tab.
- 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.
- Click on the "Content" tab and enter "Hello world!" into the "Content" box.
- Click "OK".
- 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:
- Open Visual Studio.
- 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". - Delete the default "Class1.cs" class if present.
- Add a new class to the library named "HelloWorldClass".
- Right click on your project in the solution explorer and click "Manage NuGet Packages for Solution."
- Click on the "Browse" tab; search for and install the "Contensive.CPBaseClass" package.
- Go back to your "HelloWorldClass" and paste the following sample code.
- 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 "Hello World" text returned by your .NET C# program:
- Right click on your solution in Visual Studio and click "Open Folder in File Explorer".
- Navigate to \HelloWorldAddon\bin\Debug and copy "HelloWorldAddon.dll". The .dll files are referred to as "Assemblies".
- 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.
- Back to your website, find your "HelloWorld" Add-on in the navigator and go to the edit menu.
- Click on the "Code" tab.
- In the "DotNet Namespace.Class" field, enter "HelloWorldAddon.HelloWorldClass".
- Click "OK".
- 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.