The original and best strengths of the DNN platform are how easy it is to create your own content and how easy it is to extend the platform for specific content creation like blogs, forum, e-commerce or anything your imagination can dream up.
Following on from the ease of creating new content is the ease of creating a new skin for sites, to deliver a consistent look and feel for sites in a way that leaves designers free to create compelling experiences for visitors.
The DNN story has always been one of simplicity of use, coupled with the power of extensibility when more customization is required.
DNN 7.1 continues this story when it comes to the URLs of a DNN site. Creating great-looking URLs is part of the DNN 7.1 experience. And the control over URLs does not stop there – those wishing to customize the way URLs look for more advanced functions now have the ability to extend URL behavior beyond the standard DNN handling. The power of having a great standard and easy extensibility now applies to the URL scheme of a site as well.
A new extensibility option : Extension URL Providers
Extension URL Providers are DNN Extensions just like skins or modules. Instead of changing the appearance of content or the design of a page, it allows the modification of the URL for the page, or allows specific handling of URLs such as to return a redirect to a different URL, or to return a ‘404 Page Not Found’ error.
This mostly applies to URLs that are used for DNN modules to display content. By default, any content module that has the ability to vary what is shown on a DNN page includes some module-specific information mixed in with the DNN page path.
The Social URL Provider : An Example Extension URL Provider
As an example, the Social Groups module that ships with DNN displays a specific Social Group by appending the Group Id of the module to the end of the DNN page to create the URL that applies to that group.
A new Social URL Provider has been created for DNN 7.1, which can transform the URLs for Social Groups, removing the ID-based URLs and replacing them with URLs based on the name of the Social Group.
http://example.com/social-groups/GroupId/365
What an Extension URL Provider can do is the following:
- Simplify the URL to remove the DNN Page Path (social-groups) from the URL
- Swap out the database-id specific URL reference for one that shows something more meaningful, such as the name of the Social Group
- Redirect from the GroupId/xx style URL to the name-based URL.
After installing an Extension URL Provider, you can achieve a URL for the listed social group as:
http://example.com/my-social-group-name
In order to produce a simplified URL like the above, there are 3 actions that need to be handled:
1. Generation of the URL
2. Rewriting of the URL
3. Redirection of the URL
Generation of the URL is all about taking the raw pieces of the URL – the domain, the segment of the path that refers to the DNN page, and the segment of the URL that refers to the non-DNN core parts of the URL – usually the parts that refer to a blog post, product listing, forum thread or whatever other piece of content displayed on a DNN page. In the case of social groups, the provider takes the GroupId and uses it to find the Group Name. It then ‘cleans’ that name for URL purposes, removes all the ID-related parts of the URL and then substitutes in the Group Name in URL form.
Rewriting of the URL is the process of taking the friendly URL and transforming it back into something that the underlying code understands. In the case of Social Groups – it means taking that Group Name, and translating that back into the GroupId so that the underlying Social Groups module can retrieve the correct content from the database and display it.
Redirecting of URLs is the task of allowing a transition from a site which doesn’t use an Extension URL Provider to becoming one that does. There is usually a large amount of existing content for modules that have been around for a while, so all the old URLs need to be redirected to the newer, better URLs. This is the process of redirection. This function can also be used for creating custom migration scripts – such as migrating from one module type to another – for example, redirecting from one blog module to another blog module and making sure the old posts were found at their new locations.
More Detail : About Extension URL Providers
Extension URL Providers are a DNN extension that handle these three functions by linking directly in with URL handling at the appropriate points in the DNN platform. They are a fully-compiled solution that can implement anything that can be written in .NET code- and that is a universe of possibilities. Extension URL Providers only work with DNN 7.1 when the Friendly URL Provider mode is set to ‘advanced’.
Many attempts at solutions for this problem space start around sets of Regular Expressions embedded in rule files – whether using the in-built DNN functionality, or an external solution like the IIS URL Rewrite module. I’ve even built rules-based solutions in the past. And that is where the DNN Extension URL Providers solution is head-and-shoulders above the other ways of solving the URL puzzle. Because you can use more powerful techniques, read data from databases or config files, you can create more powerful and better-resolved solutions.
Extension URL Providers are built by inheriting from an in-built DNN type, and implementing the pre-defined methods. A Provider can be associated with a specific DNN Module by specifying the Module name. When this is done, the underlying URL framework can associate the URLs on DNN Pages with a specific Provider, and calls that Provider when required. This process is transparent to the Provider- the code inside just needs to respond to the parameters provided and return the result.
Getting Started : Where to next?
You can dive deeper into the technical detail by visiting the Extension URL Provider wiki jumping off point. This gives a more in-depth discussion of the finer points of Extension URL Provider design.
You will also want to visit the DNN Extension URL Provider Codeplex project page – you can download the Social URL Provider for 7.1 and install it in your 7.1 site, and you can download the source code and see how it is put together. This project makes a suitable base to copy from if you’re thinking of building your own provider which matches the use-case of having an id-based URL and replacing it with a more descriptive name.
I will be building more Providers and hosting them at the same Codeplex project – if you have anything you would like to contribute, please get in contact and we can put up more Providers. It is my hope and intention to have a number of these created for common DNN modules and tasks, and for Commercial Vendors to start offering these as part of their products.
Got any comments? Can you think of any DNN Modules that are crying out for an Extension URL Provider? Please share in the comments box below.