Sharepoint / MOSS url rewriting

For the current project I'm working on I needed to get rid of MOSS' /Pages - the client wants nicer looking URL's.
I came across this project which is really simple to use: UrlRewriter

Installing it in SharePoint is also really simple, especially since UrlRewiter is already signed. Just simply GAC the assembly, and add the following to the web.config:

<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter, Version=, Culture=neutral, PublicKeyToken=0573f3650687980d" />
<SafeControl Assembly="Intelligencia.UrlRewriter, Version=, Culture=neutral, PublicKeyToken=0573f3650687980d" Namespace="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler" TypeName="*" Safe="True">
<add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter, Version=, Culture=neutral, PublicKeyToken=0573f3650687980d" name="UrlRewriter" />

Finally add this in the configuration section:

<if url="^((?!/Pages/|/Style%20Library/|/Style Library/|/_layouts/|/).+)*$">
<rewrite to="/Pages/$1" />

UrlRewriter uses a regular expressions in order to match and replace the url:
^((?!/Pages/|/Style%20Library/|/Style Library/|/_layouts/|/).+)*$

So this will find all url's that don't start with /Pages/ and add it on.



After a long wait I have finally got my MCP ID!

The plan is to get all the developer and sharepoint certs...


Sharepoint: The object specified does not belong to a list

I had a problem this morning, with a custom control that I am using in PublishingPages and admin pages in the _layouts folder.
The control looks for some custom properties in the current pages ParentFolder. However when checking the SPFile.ParentFolder.Item property in a page located in _layouts it throws an exception - "The object specified does not belong to a list".
My first thought was to check for SPFile.ParentFolder.Item != null, but that didn't work. However by setting a break point I discoverd that folders in the _layouts directory don't exist!

So use: if(SPFolder.Exists) {}


WSS coding best practice

This article is a must read: http://msdn2.microsoft.com/en-us/library/ms778813.aspx

I've been having a few memory problems lately in the project im currently working on. I thought I was correctly disposing of all my SPWeb and SPSite objects but I didn't realise that even accessing SPFolder.ParentWeb would create a new instance if one wasn't available.


Two useful WSS v3 resources

Just a quick post.
I found these two resources useful today.
The first is a step by step guide to installing and configuring MOSS in Virtual PC. The steps are very clear and surprisingly everything went according to the guide - no small feat!

The second is a look at the process of developing with WSS. It has a really good look at packaging a project into a solution that can be deployed to a server.


Oconics expands

We were in the paper today!

Very cool!

jQuery Manager for .Net

I released the early version of my jQuery Script Manager today on CodePlex.
Its an idea that I have had for the past couple of days in an attempt to make using jQuery and ASP.Net work nicely. I've been using JavaScript lately with SharePoint (WSS v3 & MOSS) and I've been unhappy with how injected JavaScript can get really messy. This project is an attempt to make it better.

What is jQuery you ask?

So here is how its currently used:

1) Add the jQuery Script Manager to the page

<%@ Register Assembly="jQuery.ScriptManager, Version=, 
Culture=neutral, PublicKeyToken=null
" Namespace="jQuery.ScriptManager" TagPrefix="jQuery" %>


<jQuery:jQueryManager id="jQueryM" runat="server">

2) register any JavaScripts functions that need to run on document.load

<jQuery:jQueryManager id="jQueryM" runat="server">
<jQuery:RegisterReadyFunction FunctionName="TestFunction" />

3) Create the JavaScript function

function TestFunction(){
alert('The page has loaded!');

The JavaScript function "TestFunction" will be called when the page loads by placing it in jQuery's $(document).ready function.


Embedding JavaScript as a resource in a .Net assembly

I needed to do this today for a web part that I'm creating. Being able to have the JavaScript packaged is so much neater.


ASP.Net AJAX and MOSS 2007

This post from Mike Ammerlaan just saved me some time on what to add to the Web.config for MOSS.

MOSS 2007 WebPart CAS

This is a good article on MOSS CAS - saved me some time!

I also discovered the hard way that if you use the sample config file associated with the article bad security things will happen. This is because WSS does not have permission to access the file, so I copied the wss_minimaltrust.config, and then copied the contents of the sample file into it.


Time to leave

I've decided that after 3 good years at UniSA that its time to leave.

I've had a great time there and have learnt a lot, but I really felt that it was time to move on.
I'm looking forward to the new challenge and hopefully I'll be more motivated to update this blog as I'll have new things to say!