Custom Transforms
Custom transforms allow you to extend the UrlRewriter.NET component by adding your own powerful text transformations that you can use in your rewriting rules.
To create a custom transform, you create a class that implements the IRewriteTransform interface. Then, you register this class as a transform.
Examples
Creating the transform class
If you wanted to map all underscores to dashes, you could define a transform class to do this:
public class MakeDashTransform : IRewriteTransform
{
public string ApplyTransform(string input)
{
// Replace all underscores with dashes…
return input.Replace(”_”, “-”);
}
public string Name
{
get
{
return “makedash”;
}
}
}
Registering the transform
In order for the transform to be recognised by UrlRewriter.NET, you have to register it.
<register transform="MyNamespace.MakeDashTransform, MyAssembly" />
Using the transform
Once the transform has been registered, you can use it as follows:
<rewrite url="/([^\.]+)(\.aspx.+)” to=”/${makedash($1)}$2″ />