0

I am migrating a site from siteA.domain.com to siteB.domain.com. All the page paths remain the same. The problem is it's a gradual migration, and not every path is being migrated at the same time. So what I need to do is check the path the user is going to, and if it's a member of a list of migrated sites, then redirect the user from siteA.domain.com/path to siteB.domain.com/path

I was hoping to add in-line c# code to the master page. Any thoughts/examples of this?

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Donaldinio
  • 596
  • 2
  • 9
  • 21

4 Answers4

0

I believe the correct way would be to add some routes to the Global.asax.

       void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        RegisterRoutes(RouteTable.Routes);
    }
            public static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapPageRoute("home",
            "home",
            "~/Home.aspx");
    }

The above code will let you type "http://mysite.com/home" and it will redirect to the Home.aspx page. You could redirect to http://myothersite.com/Home.aspx instead of using the ~, or relative path.

You can add routes for each and every page that you have in some master list.

amischiefr
  • 4,750
  • 2
  • 29
  • 22
0

I would have a list of address in your config that have been migrated, then in the page_load of the master page check the current url (on of the properties in Request.Url I can't remember which) and see if it is the list from the config.

Simple, but quite often the simple way is the best. Plus if it is a temporary thing there is no point wasting time doing anything complex.

jcvandan
  • 14,124
  • 18
  • 66
  • 103
0

Any reason not to use IIS for the redirect? SO Question - How to redirect a URL path in IIS?

Community
  • 1
  • 1
Zach Green
  • 3,421
  • 4
  • 29
  • 32
0

Create an IHttpHandler that intercepts all incoming requests and redirects appropriately.

Chuck Savage
  • 11,775
  • 6
  • 49
  • 69