Getting the ASP.NET Forums to Actually Work

I decided to download and install the ASP.NET Forums for DotNetAtlanta.com.  I thought this would be a simple task, but it was not as simple as it should be.  The download installed the web application, database, and source code locally just fine.  However, those of us that use shared web hosts, like WebHost4Life, can't just run an exe to install our apps.  Still, how hard can it be I figured -- just copy the web files and run the database scripts.  I took my time with the database scripts, since I needed to make sure they didn't drop and try to recreate my database.  I also needed to make sure they pointed to the correct database, instead of the default database name.  Still, I got several errors that I didn't really understand the significance of at first.  It turns out that the scripts assign dbo as the owner for the tables, but not for the views, stored procs, or user functions.  This required a search for a script to fix this problem, one of which I know was posted here very recently.  There were also two procs that required some changes (forums_GetAllForumGroupsForModeration, forums_GetForumsForModerationByForumGroupId).

Finally I had the Forums working on my site, but in testing it became apparent that the email functionality didn't work.  This one was very tough to figure out, since a search in the Forums revealed other people having this problem with no solution.  Sure, there were good suggestions that worked for many people, like change the smtpServer element in the web.config file, and change the sender email address in the database.  But these suggestions did not fix my problems, nor did they obviously fix it for others, and yet that was all the forums had to offer.  I created a test page with the same smtpServer and sender email address using the simplest code possible, and it worked, so the problem was with the Forums source code itself!  I altered the source code to remove the try/catch around the send email method, and turned off the custom error setting so I could see what was going on.  I got one of the strangest error messages I had ever seen that directed me to another site for a better description.  The problem then became apparent -- the email RFCs prohibit line-feeds without carraige returns, and some smtp servers enforce this, including the qmail sender used by WebHost4Life.  The problem was now easy to resolve by altering the Forums source code and recompiling.

So now I have working Forums on my site, but I was still lacking my standard header menu.  Its just amazing to me that these projects available from Microsoft don't include MasterPages or some other page template technique.  By the way, I was asked by someone why I wasn't using the Community Starter Kit -- because it sucks!  Really, none of these samples for portals are based on flexible and maintainable architectures, and I have a pretty good one already.  Anyhow, I did not want to change 40 individual pages, so I turned on tracing and found a pretty good pattern.  All I had to do was create a base page class that looks for the HtmlForm in the AddParsedSubObject method, and then dynamically add a header and footer control appropriately.  Very easy and worked like a charm, and its generic enough to be useful for probably many other ASP.NET sites out there too, so its posted here.  I also tampered a little bit with the source code for Avatars, but that's definitely an extra to simplify things for me, and now my Forums work well.

1 Comment

Comments have been disabled for this content.