Using ASP.NET to help Fibromyalgia sufferers.

It's been a really long time since I did any ASP.NET development (about 2 years) and a lot really has changed over that time! 

As I've posted about before, my wife has a chronic condition called Fibromyalgia (Fibro) for which there isn't a lot of awareness, even amongst GPs, in the UK.  Despite this she's managed to get her condition under control and is now heading a new national charity (called FibroAction) to help others with her condtion who haven't been so lucky.

What this means obviously is that I was volunteered to develop the charity's website.

Given that all I do these days is Silverlight and WPF, I was a little worried that I'd struggle to remember how all that HTML, CSS and ASP.NET stuff worked.  However I was pleasantly surprised at how easy it was.

I am very impressed with Expression Web and the new design surface in VS2008, and I love the LinqDataSource, it makes building applications very fast.

All in, it took me about 3 weeks of playing in the evenings to get a fairly good (if I do say so myself) site that is content managed, allows user registration and should be fairly easy to restyle in the future.

I also had my first go at making a site search engine optimised.  Having spoken to a couple of colleagues I implemented some really simple solutions.  First off was to kill two birds with one stone.  By making the site accessible it also makes it crawlable.  After that was doing some url-rewriting so that the content managed pages didn't have a nasty query string, but a human readable url.

To do that, inspect the incoming url (in Application_BeginRequest() of Global.asax) and parse it to determine the type of page.  So for example

mysite.com/pages/my-page.aspx would get rewritten to mysite.com/serverpages/page.aspx?pageId=1 and mysite.com/articles/my-article.aspx would be rewritten to mysite.com/serverpages/articles.aspx?articleId=1.

The articleId and pageId are determined by having a calculated column on the database table for articles/pages which is a unique string calculated from the title.  So if you have two pages with a title of "My Page" they would be accessible as /pages/my-page.aspx and /pages/my-page-1.aspx.  All you need to do then is query the page against the calculated column, get page/article id and then rewrite!

protected void Application_BeginRequest(object sender, EventArgs e)
{
if(Request.Path.Contains("/page/")
  {
MyDataContext dc = new MyDataContext ();
// Logic to split title from path
    var page = dc.Pages.Single(p => p.PageTitle == splitTitlePath);

this.Context.RewritePath("/ServerPages/Page.aspx?pageId=" + page.PageId);
}
}

Technorati Tags: FibroAction,Fibro,Fibromyalgia,ASP.NET,Linq,SEO,url rewriting,rewritepath,Medicine 2.0