I forgot to say that we are using version 5.1.422.122 (which is SP1 I think).
Any other ideas would be great....
Jim.I would not do this on the page but rewrite the url before it reaches the page.
A (untested) suggestion is to add your own event handler to Global.UrlRewriteProvider.ConvertedToInternal and look at e.Url. If you want to change language you can either issue a response redirect with abort or modify the query paramter epslanguage to show another language.
If the parameter idkeep is present do not do anything because this is a preview request for edit mode.
/Fredrik
Thanks for the ideas Fredrik,
I had a look at this, but I don't have access to the information I need at the point when the ConvertedToInternal event fires. The Response object is not available, and therefore I cannot tell what language the user expects to see.
I did modify my previous code from
if (this.CurrentPage != null)
to
if (Request.RawUrl.ToLower().IndexOf("idkeep=true") == -1)
to stop it redirecting when in preview mode. The trouble is that this didn't fix the issue. I have now removed the redirect code and the issue still occours. I've used Reflector and it looks like it's because the CurrentPage value is null. I assume this is usually the case, so am not sure why it's causing this problem.
Any ideas on the cause?
Jim.
i.e. www.test.com/page1 would redirect to www.test.com/en/page1.
To do this I added the following code into the PreInit event handler of template page:
This code works fine except when you are looking at previous versions of page. If you go into the Version List tab and select a previous version of the page and then press the View tab you get the following exception:
When I first did some investigation I noticed that the CurrentPage property of the page was not being populated, so I had to add some code in various places to make sure it would not throw exceptions.
I suspect that the above exception is due to the same issue, however I'm not sure how to get around it? Am I doing the right thing in the redirection code, or should I do it in a different way and that would not cause this issue?
Any ideas or suggestions would be gratefully received.
Jim