BlogEngine.NET Extension for Graffiti CMS

In my previous post I moved away from Graffiti CMS to find the perfect blog engine for me, in the journey I found BlogEngine.NET, perfect name for what I was looking for, yet I spent some time after the migration using BlogML to make sure all the urls still work, so all people that get into my blog from searching, almost all, still can find the correct post by the link. There is nothing worse than a broken link isn’t it? I made some modifications to BlogEngine.NET as a form as a extension, that is nothing else than a HttpModule.

Now Graffiti uses the category as a link and creates a directory per post if running under IIS6, I was wise when using Graffiti CMS to add all post blogs under blog, so all posts have the link of blog on the url, something that BlogEngine.NET is the post directory. So I had to make sure any request to blog will be handle by my httpmodule. Now if you are running your BlogEngine.NET under IIS6, you still need to create a directory called blog, otherwise your httpmodule won’t be called, if you are running under IIS7, you don’t have to worry about that one.

As I said before Graffiti CMS creates a directory per post blog, in BlogEngine.NET, every post is a aspx page, so modules can redirect them, that’s why my module rewrites the end of the title to .aspx.

Also a few spaces in Graffiti are converted to dashes (-) and in BlogEngine.NET some are removed, so I had to check a few URLS and removed those, instead of hard coding it as I did for the test, I am working in a XML file that I can add as many changes as I want.

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Linq;
   4: using System.Web;
   5:  
   6: namespace Al
   7: {
   8:  
   9:     /// <summary>
  10:     /// Summary description for GraffitiModule
  11:     /// </summary>
  12:     public class GraffitiModule : IHttpModule
  13:     {
  14:         public GraffitiModule()
  15:         {
  16:             //
  17:             // TODO: Add constructor logic here
  18:             //
  19:         }
  20:  
  21:         #region IHttpModule Members
  22:  
  23:         public void Dispose()
  24:         {
  25:             //
  26:         }
  27:  
  28:         public void Init(HttpApplication context)
  29:         {
  30:             context.BeginRequest += new EventHandler(context_BeginRequest);
  31:         }
  32:  
  33:         void context_BeginRequest(object sender, EventArgs e)
  34:         {
  35:             HttpContext context = ((HttpApplication)sender).Context;
  36:  
  37:             if (context.Request.Url.OriginalString.ToLower().IndexOf("/blog/") > 0)
  38:             {
  39:                 string sOriginal = context.Request.Url.OriginalString.ToLower();
  40:  
  41:                 sOriginal = sOriginal.Replace("/blog/", "/post/");
  42:                 sOriginal = sOriginal.Replace("default.aspx", "");
  43:                 sOriginal = sOriginal.Replace("sql-server-compact-edition-3-5-in-visual", "sql-server-compact-edition-35-in-visual");
  44:                 sOriginal = sOriginal.Replace("4-0", "40");
  45:                 sOriginal = sOriginal.Replace("3-5", "35");
  46:                 sOriginal = sOriginal.Substring(0, sOriginal.Length - 1);
  47:                 sOriginal = sOriginal + ".aspx";
  48:  
  49:                 context.Response.Redirect(sOriginal);
  50:             }
  51:         }
  52:  
  53:         #endregion
  54:     }
  55: }

 

   1: <httpModules>
   2:       <add name="GraffitiModule" type="Al.GraffitiModule"/>
   3:         

Hope that helps anybody moving to BlogEngine.NET can use this idea, when I got some time to finish my real Extension with a configuration, I’ll make sure to share it here.

I got a few emails this week of people asking me, why the change to BlogEngine.NET instead of SubText, well, the answer is simple, besides http://darkfalz.com/ told me, as well as the code was very easy for me to grab that application and write the changes I wanted to make, yet I personally love the mobile theme that BlogEngine.NET has for the iPhone.

Cheers

Al



Published Wednesday, June 02, 2010 10:04 PM by albertpascual

Comments

# Dew Drop &#8211; June 3, 2010 | Alvin Ashcraft&#039;s Morning Dew

Thursday, June 03, 2010 12:30 PM by Dew Drop – June 3, 2010 | Alvin Ashcraft's Morning Dew

Pingback from  Dew Drop &#8211; June 3, 2010 | Alvin Ashcraft&#039;s Morning Dew

# re: BlogEngine.NET Extension for Graffiti CMS

Friday, June 04, 2010 2:57 AM by Sonic Producer

let me say, what was yours experiences to use of BlogEngineNT, Is it really effective in all respet ???

# re: BlogEngine.NET Extension for Graffiti CMS

Friday, June 04, 2010 5:26 AM by Pro Cleanse Gold

yaa... Graffiti CMS creates a agenda per column blog, in BlogEngine.NET, every column is a aspx page, so modules can alter them, that’s why my bore rewrites the end of the appellation to .aspx.

# re: BlogEngine.NET Extension for Graffiti CMS

Monday, August 02, 2010 1:44 AM by How To Get Him To Propose

What a Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.

# re: BlogEngine.NET Extension for Graffiti CMS

Saturday, November 13, 2010 5:20 AM by Cpap Mask

Hello,I love reading through your blog, I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts.

# re: BlogEngine.NET Extension for Graffiti CMS

Wednesday, December 29, 2010 1:18 AM by The Flex Belt

Nice information, many thanks to the author.

It is incomprehensible to me now, but in general,

the usefulness and significance is overwhelming.

Thanks again and good luck!

# re: BlogEngine.NET Extension for Graffiti CMS

Wednesday, December 29, 2010 4:33 AM by Smokeless Cigarettes

I like what I have read so far

# re: BlogEngine.NET Extension for Graffiti CMS

Friday, December 31, 2010 12:45 AM by Smokeless Cigarettes

I like what I have read so far

# re: BlogEngine.NET Extension for Graffiti CMS

Wednesday, January 05, 2011 5:06 AM by Comparateur Bookmaker

Nice blog. Best regards.

# re: BlogEngine.NET Extension for Graffiti CMS

Wednesday, January 05, 2011 7:58 AM by employment software

This is the good step u have taken. Thanks for writing this, it’s clear that you have spent a good amount of time on your sites development

Leave a Comment

(required) 
(required) 
(optional)
(required)