Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Josefson 15 posts 37 karma points
    Sep 06, 2011 @ 01:53
    Peter Josefson
    0

    Adding UrlRewriting rules programmatically on application start

    Hi,

    Has anyone succeeded in (or even tried) adding/inserting UrlRewriting rules programmatically during umbraco startup (an ApplicationBase-derived class constructor)? I'm out of ideas here...

    My rules work perfectly when added to UrlRewriting.config, but when I try to add them from my app class, nothing happens. And yes, I'm doing some logging to my own database and my code does get called, produces the correct strings and so on, and there are no exceptions. It... just doesn't work...

    I've read the UrlRewriting documentation fifty times and tried every conceivable (to my mind) reasonable combination of options and parameters (just in case something got lost in translation from German).

    After thinking that umbraco perhaps got higher in the list than I did, I created a dummy rule in the .config file and told UrlRewriting to insert my dynamic rules before the dummy rule. Nope. Just doesn't "take".

    Any clues?

    Why do I need it? Becase I have a customer with a multilingual (around ten languages, still counting) site, and the word "products" is NOT the same in all languages - I need to identify requests to a product database and convert the trailing parts of the path (which is something like "/en/products/thiscategory/thatsubcategory/thisproduct/" into a query string. And I would like it for the customer to be able to add languages and/or correct translations without involving me...

    I would VERY much like to do that programmatically. I can catch events and notice when the customer adds countries or corrects a misspelling of a translation of "products", and track them in MY database (which is actually prepared to talk to me during app startup). So far, all is well. But as for doing someting about it - inserting the rules - not so much...

    *sigh*

  • Rich Green 2246 posts 4008 karma points
    Sep 06, 2011 @ 08:37
    Rich Green
    0

    Hey Peter,

    I don't have the exact answer you're looking for but prehaps you could do this a different way? I'm assuming that requests to the product without the correct spelling would generate an 404? You could catch the 404 and add some logic that looks at a list of words/nodes added by your client and then redirect or handle the request in your code?

    Regards

    Rich

Please Sign in or register to post replies

Write your reply to:

Draft