Redirecting Traffic from an Old Web Site to a New One ASP.NET

When you change hosting providers, you get new a IP for your servers.If you change your DNS configuration for your site to the new IP, it takes about four days to propagate through all the ISPs. During this time, users will hit the old IP, get no response, and assume the site is down.So,we need a way to redirect users to the new IP when they go to the old one.

Redirecting Traffic from an Old Web Site to a New One

Problem: Changing hosting providers threatens the user experience and costs you money.

Solution: Redirect traffic to an intermittent subdomain.

At Pageflakes,we had all sorts of problems with our hosting providers and,at one point, had changed hosting providers almost once every four months.So, we had to come up with a solution that works transparently and without any downtime.Here’s what we do:

  1. Map a new subdomain, such as new.pageflakes.com, to the new server IP.Then we create a new web site (not virtual directory) on the old web server called Redirector. It maps to a folder that has nothing but global.asax and web.config

    Setup a Redirector web site on an old server that forwards users to the new server

    Setup a Redirector web site on an old server that forwards users to the new server

  2. Go to Redirector, navigate to Web site Properties ➝ Home Directory ➝ Configuration,and map ASP.NET to receive all web requests. This includes all URLs, including .html,.gif,.css, and .js, etc.

    Configure ASP.NET to receive all requests including requests for .html files

    Configure ASP.NET to receive all requests including requests for .html files

  3. Write the code in Example to Global.asax, which redirects all traffic to the new server.

    In Global.asax,theApplication_BeginRequest intercepts all calls and redirects users to the new server

    The Redirector keeps the query string and logical path intact.So, complicated URLs like www.sometagetdomain. com/something/ somefile.html? someparam= somevalue are converted nicely.
  4. Stop the default web site that is listening to port 80 and turn the Redirector web site on. Before you turn off the default web site, ensure the new server is alread up and running on the new subdomain. Change the DNS and map the new server’s IP to your main domain site.

    So, users that still have the old IP in their DNS cache go to the old server and are redirected to the new server.But after a while, when their DNS cache is refreshed and they get the new IP, their requests go to the new server and no redirection is required. After four or five days, you can safely bring down the old server.



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

ASP.NET Topics