11

I have implemented URL redirection in one of application in asp.net and Tridion. Whenever I add any new redirect URL, I have to restart the application pool to reflect the changes because I am maintaining these redirect URLs in a configuration file which is referenced in the web.config file through configSource attribute as below –

    <httpRedirect configSource="HttpRedirect.config" />

Could anybody suggest me the way to get changes reflected immediately without restarting app pool? Is there any way to get the app pool restarted automatically after any new change in the HttpRedirect.config file?

NOTE – I would not want to merge HttpRedirect.config file in the web.config due to being too large list of URLs.

Though question is fairly related to the asp.net technology. Since I know a lot of member in Tridion using asp.net can help me here. Thanks in advance.

0

5 Answers 5

10

You could do the redirection manually and pull the URL from a database table.

This would mean the redirection could be changed on the fly with a simple database update which would not need the app pool to be restarted.

1
  • 1
    @GlenH7 noted and updated.
    – Ozz
    Commented Apr 24, 2013 at 11:35
8

I have successfully used UrlRewriter.net in the past with a similar configuration as yours - a component in Tridion with the url mappings, and at publish time I would generate the required configuration file for this module.

I didn't have to restart the app pool for this to take effect, it was immediate.

2
  • Thanks Nuno , had you used <httpRedirect /> or <rewrite /> for this ?
    – user395
    Commented Apr 24, 2013 at 11:06
  • I don't understand your question. I use an open source module (UrlRewrite.Net) that does the redirects itself. In the web.config I added a section that points the configuration to the separate file, and then the module kicks in when urls are requested that match the urls patterns as defined by my rules...
    – Nuno Linhares
    Commented Apr 25, 2013 at 9:53
6

Frankly I do not have any experience on this particular stuff so cannot say anything about why it is working with Nuno and not with you. May be you both are maintaining the cache differently in your application.

But keeping your concern in to mind I can suggest you a work around here.

As I know that changes to configuration setting in the web.config file cause the application domain to restart automatically and if you are doing any change in the external config file referenced in to web.config through the configSource attribute application domain will not get restarted automatically. Here is a simple work around -

“Just publish your web.config file also along with HttpRedirect.config”.

By doing so your application domain will get restarted. You can do it through the Tridion code or manually

2
  • This seems like the most simple solution but there may be considerations around caching etc. Commented Apr 25, 2013 at 12:28
  • Yes ,I agree with you Rob that's why I said it a workaround. if someone covered a long way with an implementation , he can go with this workaround :-) Commented Apr 25, 2013 at 13:07
5

You may want to consider using a 'Custom Rewrite Provider' with the standard 'URL Rewrite' module. This would allow you to use an external file (published from Tridion) to manage the URLs. There are further details on this here.

There is example code, linked to from that page, for "Storing of the rewrite or redirect mappings in a text file". You could publish these text files from Tridion. I am fairly sure from memory that the App Pool does not need to be recycled to pick up changes to the published files.

2

Not an ideal approach (another work-around), but if the httpredirect.config file is kept in the bin directory, your application pool will automatically restart whenever the file is updated. Any file change in the bin folder causes the application to restart.

This is not ideal for numerous reasons, performance being one. Users visiting during the restart will experience a slower "experience" as the website spins up and cache's are repopulated etc...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.