Optionally provide private feedback to help us improve this article...

Thank you for your feedback!

Using the InstantForum .NET API

We've made it very easy for developers to take advantage of the InstantForum API from your existing ASP.NET based web site or web application. To take advantage of the InstantForum API from your own Visual Studio projects please follow the steps below.

1. Add References to our .NET Assemblies

Right click on your web site within Visual Studio solution explorer and locate the "Add Reference " option...

This will display the Visual Studio Add Reference dialog. Select the "Browse" Tab and locate the InstantForum Bin directory. Then select the following files....

Select the assemblies listed below from your InstantForum installation…

  • InstantASP.Common.Configuration.dll
  • InstantASP.Common.Data.dll
  • InstantASP.Common.dll
  • InstantASP.InstantForum.Data.dll
  • InstantASP.InstantForum.dll

This will ensure you have access to all the methods within our API. You do not need to add the .UI assemblies to your application unless you wish to use the server controls provided by the InstantASP.Common.UI namespace.

2. Add the InstantForum database connection string to your web sites web.config file

To ensure our API knows where to look for data you'll need to provide a database connection string within your web.config file. You can do this either within the <appSettings> or <connectionStrings> section of your web.config. Both examples are provided below...

App Setting

<add key="InstantASP_ConnectionString" value="server=localhost;uid=Username;pwd=Password;database=InstantForum"/>

Connection String

<add name="InstantASP_ConnectionString" connectionstring="Server=localhost;trusted_connection=true;database=InstantForum;"></add> </connectionstrings>

3. Add the InstantForum path to your web sites web.config file (optional)

This indicates the virtual path to the InstantForum installation from the root o your web application referencing our assemblies. For example if InstantForum is installed in a child folder under your main site within a folder called "forum" this application setting would look like...

<add key="InstantASP_VirtualPath" value="Forum"/>

If you install the forum to a web application located at c:\test\ but you wanted to add the forum to c:\test\forums\myforum\ you would modify the setting InstantASP_VirtualPath to read "forums/myforum"…

<add key="InstantASP_VirtualPath" value="forums/myforum"/>

4. Testing the references are working correctly

To quickly test the references are working correctly lets return some user data using the InstantForum API. You can use the following code to get an instance of the default administrator account provided with InstantForum and display some user properties on your page…

public class _Default : System.Web.UI.Page
	protected void Page_Load(object sender, System.EventArgs e)
		InstantASP.InstantForum.Components.User User = new InstantASP.InstantForum.Components.User(1);
		if (User.UserID > 0) 
			Response.Write("User Information");

Why do I need the InstantASP_VirtualPath setting?

InstantForum needs to know where to find localization & continuation files for some operations within our API. For example all page names are held within the "Pages.config" file within InstantForum. This allows you to use our API to get forum URLs. For example if you wanted to populate a hyperlink to a specific forum you could use…

hypMyLink.NavigateURL = "~/forums/" + InstantASP.InstantForum.Globals.Paths.Forum(intForumID)

In this instance InstantForum will attempt to look within the "Pages.config" file within the root of an InstantForum installation to get the name for the forum page. Providing the InstantASP_VirtualPath path setting allows our API to correctly locate these files and use the values you've defined.

If you don't provide a InstantASP_VirtualPath path setting InstantForum will fall back to use the default settings for paths and settings within Pags.config & other files simply won't be used.

If you copy the Pages.config & URLRewrite.config files into the root of your own ASP.NET project referencing our assemblies you can ignore this setting. Our assemblies will always look for Pages.config & URLRewrite.config in the root of your web application unless you provide a InstantASP_VirtualPath setting as shown above.

I get a "The ConnectionString property has not been initialized" error?

This error occurs if you've not provided the required database connection string so our API knows where to look for InstantForum data. For further information please see step 2 above.