in

Bunker Hollow

Matt Williamson's home on the web, welcome.

Matt Williamson’s Blog

Personal discoveries of an IT professional.

Integrate YetAnotherForum With Your .NET Site From Source

For those who haven't heard of YetAnotherForum, it's an open-source webcontrol that gives you all of the functionality you would expect in a modern forum.  Since it's a webcontrol, you can use it as a stand-alone site or you can incorporate it into your existing web application for a streamlined and consistent look.  With this latest version you can choose to utilize the .NET membership framework, instead of the custom YAF user engine (woo hoo!).  Basically, if you've already developed a .NET web application and you've used the .NET membership framework, you can integrate a beautiful and fully-functional forum into your site in about an hour.  Here's how I do it...

Prerequisites

  1. Visual Studio and SQL Server.  I'm using VS2008 Standard and SQL Server 2008 Standard, but I believe I've read you can use the Express versions too, which are free.

YetAnotherForum 1.9.3 RC2 Source Code and an Existing .NET 3.5 Site

  1. Download the YAF1.9.3RC2 source code from the forum post or directly.
     
  2. Open the YAFVisualStudio2008 solution and convert it, no backup necessary if you store the download someplace.
     
  3. In the WAP Project, copy the Recommended.NET3.5web.config to the root and rename it web.config.
     
  4. Modify all the projects properties in the solution to build with the .NET 3.5 framework, instead of the default .NET 2.0 framework.
     
  5. Build.  Should build successfully.
     
  6. Compare your YAF web.config with your own site's web.config.  This is the trickiest and most time consuming part.  Your web.config must contain all the necessary keys, assemblies, etc if you want YAF to work correctly once you incorporate it into your site.  In particular, pay close attention to:
     
    A.  All the config keys (app, db, mail, etc).
    B.  Assemblies section
    C.  Membership Providers sections
    D.  System.CodeDom section
    E.  Runtime section
     
    Additional documentation on the web.configs is available here and here.  You must read these in order to set things up properly.
     
  7. Make all the necessary changes to your web.config above and make sure your solution compiles and runs.
     
  8. In my case, the forum will reside in ~/members/forum.  (if you do the same, make sure you change the optional root key to "/members/forum" in app.config).  So I created that folder and copied all the contents of the YetAnotherForum WAP project to that folder.  Move the bin files to your root directory's bin folder, then you can delete the empty WAP bin.  Move the App_Code folder to your root directory.  You can also delete the webConfigs folder.
     
  9. Create a separate Yaf database.  Somewhere in my config I specified that YAF will find the ASP.NET membership tables in my existing database, but it should use this new database for all of it's stuff.  I would recommend you do the same.
     
  10. Run your website and browse to the YAF install directory (~/members/forum/install/), if you encounter any Ajax errors see troubleshooting below.  Follow the instructions to install to the new database you created above.  In the last step, I always assign an existing admin user as the admin, fyi.
     
  11. Browse to the forum (~/members/forum/).  If you encounter any Ajax errors see troubleshooting below, otherwise it should work!  For some reason all the images except for the top banner work, but that doesn't matter in my case because I then create my own Default page which uses my masterpage layout and doesn't include the banner, like this:
     
    <%@ Page Language="C#" MasterPageFile="~/_MasterPages/MyMasterPage.Master" AutoEventWireup="true" ValidateRequest="false" CodeBehind="Default.aspx.cs" Inherits="MyProject.WebSite.Members.Forum.Default" Title="AASP : Members Forum" %>
    <asp:Content ID="cntHead" ContentPlaceHolderID="cphHead" runat="server">
        <title>MyProject : Members Forum</title>
    </asp:Content>
    <asp:Content ID="cntContent" ContentPlaceHolderID="cphContent" runat="server">
        <br />
        <YAF:Forum runat="server" ID="forum"></YAF:Forum>
    </asp:Content>
     
  12. I then copy my theme to the themes folder, which I've made available for download here.  It's basically the YafPro theme with Gray/Silver colors and the YafVision page icons instead of the YafPro folder icons.

Troubleshooting

  1. I encountered some AjaxControlToolkit runtime errors once I integrated the site and ran the application.  I compared the AjaxControlToolkit.dll from my website with the one used in one of the Yaf projects and they were different sizes, different versions.  So I replaced my version of the dll with the one from YAF and all was good.

Comments

 

Iain Norman said:

I've done the same with the alpha, and then forgot it all when the beta came out so went through all the pain again.

Needless to say I didn't write it down that time either!

Now it's time for RC2 and your notes are gonna help lots.

The ajax controls version issues I solved in a different way. Instead of using YAFs old versions I used bindingRedirects in the web.config.

Like so:

 <runtime>

   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

     <dependentAssembly>

       <assemblyIdentity name="AjaxControlToolkit" publicKeyToken="28f01b0e84b6d53e" />

       <bindingRedirect oldVersion="1.0.20229.26329" newVersion="3.0.11119.25533"/>

     </dependentAssembly>

   </assemblyBinding>

 </runtime>

November 12, 2008 3:52 AM
 

Matt said:

Thanks for your suggestion on the Ajax problem.  I like that solution better.

November 15, 2008 1:17 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
Powered by Community Server (Non-Commercial Edition), by Telligent Systems