urlrewriter.net help RRS feed

  • Question

  • User1855289947 posted

    I'm looking for some help on how to get friendly urls like the following: 


    http://localhost/mywebsite/products/Clothing - /products.apx?tier1=Clothing

    http://localhost/mywebsite/products/Clothing/Shoes - /products.apx?tier1=Clothing&tier2=Shoes

    http://localhost/mywebsite/products/Clothing/Shoes/converse - /products.apx?tier1=Clothing&tier2=Shoes&tier3=converse


    It would be great if it's possible to allow for an arbitrary amount of tiers (e.g. maybe upto 9 instead of just stopping at 3 as in the example above).  If not then I don't mind multiple rewrites if necessary.

    Wednesday, June 10, 2009 5:07 PM

All replies

  • User1779468316 posted

    The first step to your solution is to read the following thread http://forums.asp.net/t/1433182.aspx This will clear the 404 errors your process will create.

    The next step is to create an HttpModule and attaching to the BeginRequest event.

    Within your BeginRequest event handler,

    You will want to pass through the .axpx and any other file extensions your site uses.

    If you haven't returned for a valid file extension, then it's safe to assume that you have a frendly url to process.

    To do this you would take the rawurl from the Request object and split it on '/'.

    Next you would inspect the string[] variable let's call it parts for this example:

    You can safely assume that the parts you are interested in will be at some fixed offset in the parts array, lets call this value tier1.

    Now to get the requested value for tier1, you just use parts[tier1].

    It's best to set things up like this:

    for( int i=tier1; i < parts.GetLength(0); ++i )
      // build up your qurey string here

    Response.Redirest( String.Format( "http://yoursite&{0}, queryString) )


    Thursday, June 11, 2009 8:41 AM
  • User1855289947 posted

     I was looking for a solution using http://urlrewriter.net/ if possible - I don't want to reinvent the wheel here

    Thursday, June 11, 2009 11:04 AM