My website heavily relies on JavaScript and communicates with a .NET C# RPC service. We encountered an issue where clients' browsers cached the JavaScript, so we decided to add a version number to the URL in order to force them to use the latest JavaScript and bypass the caching problem. Whenever we release a new version, we create a new application or virtual folder in IIS with a new virtual path. For example:
http://example.com/websiteVersion10
At the root of our C# web application, we have a redirect mechanism that directs requests to the latest version from the base URL. If someone types http://example.com, they are automatically redirected to http://example.com/latestwebsiteversion. This process is controlled by a custom XML config file which we update with each release.
We noticed that clients were bookmarking the full 'redirected to' URLs instead of typing http://example.com. When we released a new version, these bookmarks would lead to 404 error pages unless we kept the old virtual paths in IIS.
To prevent this issue, one solution could be keeping all old virtual paths in IIS and adding a redirection page in each outdated website to direct users to the latest version. However, as we release updates frequently, this approach might result in numerous outdated folders both virtually and physically.
I attempted to use a custom 404 error page to redirect back to the latest version using the following code snippet:
if(OLD_URLs){
Response.StatusCode = 200;
Response.Redirect(LATEST_URL);
}
Unfortunately, this method did not work as expected and displayed a blank page instead.
Are there any more elegant solutions to avoid maintaining all old virtual paths in IIS for this purpose?