Content is still under development. For additional information please consult our community forums, knowledgebase or open a support ticket.

Contents

Documentation

Using the InstantForum.NET API


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

1. Add References to our .NET Assemblies

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



This will display the Visual Studio.NET Add Reference dialog. Select the "Browse" Tab and locate the InstantForum.NET DLL files.



Select the DLL files shown below…

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

This will ensure you have access to all the methods within our API.

2. Add the InstantForum.NET 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 within the <appSettings> section…

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

You can also use the connection string below if you have both InstantForum.NET & InstantKB.NET references within your project…

<appSettings>
<add key="InstantForum_ConnectionString" value="server=localhost;uid=Username;pwd=Password;database=InstantForum2010"/>
</appSettings>

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

This indicates the virtual path to the InstantForum.NET installation from the root o your web application referencing our assemblies. For example if InstantForum.NET 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.NET API. You can use the following code to get an instance of the default administrator account provided with InstantForum.NET and display some user properties on your page…

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim User As New InstantASP.InstantForum.Components.User(1)

        If User.UserID > 0 Then

            With Response
                .Write("User Information")
                .Write("
") .Write("-----------------") .Write("
") .Write(User.Username) .Write("
") .Write(User.EmailAddress) End With End If End Sub End Class

Why do I need the InstantASP_VirtualPath setting?

InstantForum.NET 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.NET. 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.NET will attempt to look within the "Pages.config" file within the root of an InstantForum.NET 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.NET 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.NET data. For further information please see step 2 above.





© 2011 InstantASP Ltd. All Rights Reserved. Powered by InstantKB.NET 2011-1