Embedding YAF inside an existing asp.net webstite

Modified: 2007/10/17 08:13 by prujohn - Categorized as: Installation

Table of Contents [Hide/Show]


   The problem
   Solution Summary
   How to do it
      prerequisites
      step by step
         Additional Notes


Edit

The problem

I have an existing asp.net website with master pages and lots of other stuff. How do I embed yaf into that, so I can use my existing menus and everything, with yaf appearing seamlessly as a page within the site?

If you take yaf "out of the box", then the obvious way to do this is to put the whole thing in an iframe. That kind of works, but there are a few things which don't work too well, and it's kind of complicated and unsatisfactory. In short, it's a hack.

Here's a better way to do this...

Edit

Solution Summary

Don't use yaf as an application, use it as a control and stick it in one of your site's pages which uses your existing master page(s).

Edit

How to do it

Here's how to get yaf working without the application thing. This has been tested on iis6 and iss7 with 1.9.1.2.

Edit

prerequisites

  1. Install yaf as per the instructions into a subdirectory of your main website. I use ~/yaf.
  2. Make sure that the standard installation works before you do the following, so you're only dealing with one thing at once.

Edit

step by step

  1. Use IIS manager and remove the application you created for YAF in the standard install.
  2. Move the yafnet.config file from ~/yaf to ~.
    Ensure that the yafnet.config file "points" to the place where you have YAF installed, in the example case:
    <root>/yaf</root>
  3. Modify ~/web.config.
    You need to update your main site ~/web.config with most of the contents from the old ~/yaf/web.config. Leave out all the "rewriting stuff" as you're going to switched that off later anyway. Specifically, you seem to need the following. Check carefully where this stuff comes from in the old web.config and make sure you put it in the same sections in your site's web.config. It'll bitch at you if you don't. See additional notes below.:
    • <section name="yafnet" type="yaf.SectionHandler,yaf"/>
    • <yafnet configSource="yafnet.config"/>
    • <authentication mode="Forms"><forms name=".YAFNET_Authentication" timeout="525600" /></authentication>
    • <customErrors defaultRedirect="error.aspx" mode="RemoteOnly"/>
  4. Modify ~/yaf/yafnet.config.
    Disable url rewriting. Set:
    • <enableurlrewriting>false</enableurlrewriting>
  5. Delete or rename the old ~/yaf/web.config
    This will stuff things up if you leave it there on iis6 (you will get an error message at run time of the type "It is an error to ... allowDefinition='MachineToApplication'").
  6. Copy or move ~/yaf/yaf.dll to ~/bin/yaf.dll
  7. Copy or move ~/yaf/framehelper.aspx to ~/
  8. Create and edit your new yaf forums "container" page.
    This will reference your own master page and be in your site map etc. You need to add the following lines (you can copy these from the top of the ~/yaf/default.aspx file, which you will not be using):
    Under the "<%@ Page directive" put
    • <%@ Register TagPrefix="yaf" Namespace="yaf" Assembly="yaf" %>
    • <%@ Register TagPrefix="yc" Namespace="yaf.controls" Assembly="yaf" %>
    • In the content place holder where you want to display the forums, put the control tag (you can also copy this from the ~/yaf/default.aspx file):
    • <yaf:Forum runat="server" ID="forum" />

That's it.

Additional Notes

  1. There's a line in the yaf default web.config:
    <xhtmlConformance mode="Legacy"/>
    If you're using MS Ajax at all on your site and you stick that in the site's web.config, it will break ms Ajax in strange and entertaining ways. See here for some background on this. Leave this like out and MS Ajax works again...

ScrewTurn Wiki version 2.0.14. Some of the icons created by FamFamFam.


SourceForge.net Logo Powered by ASP.NET v2.0 411ASP.NET