Yet Another Forum.NET Documention
Prerequisites
I am assuming you have Visual Studio 2005 or higher or Visual Web Developer Express 2005 or higher. Additionally if dealing with the source you'll need Visual C# 2005 or higher (express version works just fine as well). You will also need a database server of some sort, this example assumes SQL Server 2000 or 2005. Your application will have to use membership, role, and profile providers. If you are using custom providers, that's fine; however, your profile provider needs to inherit the Yaf provider (see Provider section further down). Your web project needs to be a Ajax enabled project as well (or you'll have to enable it - see
Providers and config Basics further down).
1. Download the source using svn or download the source or binary from
link2. Save in a local directory for the purposes of this example we will use
c:\Yafsrc\3. If using the source: ::open the main solution and verify that you can compile the entire solution (as Release) to your target framework (this example assumes .Net 2.0)
3. If using the binary no further work is needed
4. Create a sub folder in your application. We use
Yaf (if your app is c:\inetpub\wwwroot\Example, then it'll be c:\inetpub\wwwroot\Example\Yaf).
5. For this example we create a new database in addition to our existing database (hopefully you have one if not, step back and take a serious look at yourself; you may have issues with continuing). You can call the database whatever you'd like, I called mine
YafTest. This will really only be successful if you were not using the profile provider already, if you were you should keep evrything in one database for simplicity sake or you have some work to do. I repeat: 'Use your existing db if you were already making use of the profile provider.'
Get Ready
There are basically two things we need to do: ::1. We need to get all the files into the right place ::2. We need to combine our
web.config file with the yaf
recommended-web.config1. For this example we will use the "copy everything and delete what we don't need method" to get the files where we need them. Kind of a silly name but it works to keep your head together.
2. We'll cover the basics of combining the configs here but for a detailed step by step click
here.
Step by step
1. Copy all the files from
C:\YafSrc\YetAnotherForum.NET to
~/Yaf/ (your subdirectory in your web site)
2. If you are working from the binary version: :: open up the
~/Yaf/bin directory and cut and paste the contents to
~/bin 2. If you are working from the source version :: A. Copy the CookComputing.XmlRpcV2.dll to your bin directory and then ::::delete the
~/Yaf/bin directory :: B. Open up your project in VWD and add a reference to each dll in the YafSrc project (tedious, I know, but it's easier to refresh them when changes are made). If you missed one you'll end up with an error when you compile so don't worry about it to much. 3. Cut and past the
~/Yaf/App_Code/Yaf directory into your
~/App_Code/ directory (you'll end up with ~/App_Code/Yaf/). 4. Move the following .config files to your application root: app.config, db.config, mail.config, UrlRewriter.config. Obviously do not overwrite anything. If you already have an app.config and it consists of your application settings just copy and past the contents to yours and then delete the file from ~/Yaf/
At this point you are almost there; at least everything is in the right place. Now we just need to handle the configuration files and finally run the install.
Providers and Config Basics¶
Overview
Yaf provides external files for the database, urlrewriter, and smtp settings. You can keep these outside the web.config or combine into it, your call. Yaf also needs a place to define the membership, role, and profile providers, requestEncoding, some http modules, pages, namespaces, and some modules under system.webserver. Make sense to you? If not you should be able to muddle through by following my
steps as closely as possible.
A Few extra items: 1. Add the <root> element to the app.config <add key="root" value="/Yaf"/>
2. Check the upload directory and make sure it's correct
3. Make sure that url rewriting is turned off (it may not play nice with your site)
NOTE: If you want to integrate the YAF to your site folder "Forum", You should change app.config: Replace
with
Add this section
Ajax
As mentioned earlier you'll need an Ajax enabled Web application. This simply means you need a bunch of Ajax stuff in your web.config and your application needs to reference the ajax libraries. The basic (Asp.Net 2.0) web.config without Ajax is essentially empty; however, Ajax adds a ton of necessary things. If your application is not already Ajax enabled the best thing to do would be to create a new Ajax enabled Web site and copy the web.config over to your application and merge your stuff into that. The alternative is really not worth your time, you'll miss something and end up editing your web.config for the rest of the night.
Providers
Yaf providers are custom sql providers. You can use your own Memebership and Role providers but your profile provider must inherit the Yaf profile provider. Have you already built your cutom profile provider and inherited it from something else? If you inherited from System.Web.Profile.ProfileProvider you're ok, just change your code to inherit from YAF.Providers.Profile.YafProfileProvider. You'll want to call the base in any functions just to be sure and do some testing as well; but you should then be all right. Other wise make sure you have something like the following in <system.web>
<roleManager enabled="true" defaultProvider="YafRoleProvider">
<providers>
<clear/>
<add connectionStringName="your connection string" applicationName="Your Application Name"
name="YafRoleProvider" type="YAF.Providers.Roles.YafRoleProvider or System.Web.Security.SqlRoleProvider or whatever"/>
</providers>
</roleManager>
<membership defaultProvider="YafMembershipProvider" hashAlgorithmType="SHA1">
<providers>
<clear/>
<add connectionStringName="your connection string" applicationName="Your Application Name"
name="YafMembershipProvider" requiresUniqueEmail="true" useSalt="true"
type="YAF.Providers.Membership.YafMembershipProvider or
System.Web.Security.SqlMembershipProvider or whatever"/>
</providers>
</membership>
<profile enabled="true" defaultProvider="YafProfileProvider" inherits="YAF.Classes.Utils.YafUserProfile">
<providers>
<clear/>
<add connectionStringName="yafnet" applicationName="Your Application Name"
name="YafProfileProvider" type="YAF.Providers.Profile.YafProfileProvider"/>
</providers>
<properties>
<add name="Theme" allowAnonymous="false" defaultValue="Blue"/>
</properties>
</profile>
Note: 1. This example uses two databases, the existing and a new one for yafnet. The yafnet connection string points to
YafTest. The other points to our orignal db. Seeing as you were already using membership and roles you'll need to continue pointing those areas to your existing db. If you were already making use of the profile provider you'll also need to point that to your existing db and you'll have a problem if you create the forum in a seperate db.
NOTE: If you want to use your own MemberShip/RoleProfile Provider, You can still do that, but have to change the profile by
inherit the YAF.Classes.Utils.YafUserProfile inherits="YAF.Classes.Utils.YafUserProfile">
Finalize
Ok, done? Did you add the <root> element to your app.config? Is urlrewriting off? Is the upload directory for Yaf correct? Does your application have read/write access for this directory? Can you successfully build your application without errors?
Run your application and browse to ~/Yaf/install/default.aspx and follow the steps! If you are successful you have a working forum from here you'll want to...
Pretty it up? If you are using masterpages you can create apage in your application and add the forum object to it:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<YAF:Forum runat="server" ID="forum"></YAF:Forum>
</asp:Content>
or you can just add a link to your menu to the default page under ~/Yaf/. There is a lot you can do. You probably already have a signup or registration process so once the forum is installed you'll want to disable the registration. Additionally make sure all of your roles are correctly mapped.
That's about it.
Possible Problems
Maybe someone has run into an issue and can add to this? I know I have.
BBCode Import
The bbcode import mechanism went crazy on me. I had to change the following in C:\YafSrc\YetAnotherForum.NET\install\BBCodeExtensions.xml from <UseModule>false</UseModule> to <UseModule>0</UseModule>
Web Application
If you have a web application instead of a project, remember to right click the project and press Convert to Web Application after you have added all of the files. This will get rid of all those 2000 + errors.