Reputation: 5674
I have an old web application that's being migrated to a different system, and I need to ensure that the existing URLs are redirected to the new system. (I'm using ASP.NET MVC2.)
Usually, I can just redirect to the homepage of the new site. However, if the URLs link to a specific item, they use an HTML bookmark as follows:
http://server/old-system/#itemID
I have a lookup file and translation function to go from an "itemID" to a redirect URL, and I can accomplish the redirection using a RedirectResult.
But how can I get the anchor tag to the server as a query string parameter (anchor tags aren't sent in HTTP requests)? I assume I'll need some kind of client-side javascript for this to invoke a separate server method, but I'm not sure how to do that translation.
(Note, the whole reason for doing this is that clients may have stored a bookmark link to an item.)
Thanks!
Upvotes: 2
Views: 2625
Reputation: 284
If http://server/old-system/#itemID
is a page in your system you can do a quick translation in javascript.
window.location.href.replace('#','?link=');
or get the value and link to another page.
window.location = "http://server?itemID="+window.location.hash.replace('#','');
Upvotes: 5