Question

First of all, we are using MVC 3, ASP.NET 4.0 and Visual Studio 2010.

Our goal is to open up our brand new web site to an open beta. We want to redirect a slowly increasing percentage of our traffic to our new site while the rest of our traffic goes to our existing site...

We were hoping to do this via a load balancer, but this is no longer an option due to resources, infrastructure and time. Right now it seems our only option is to do it via software.

Has anyone here done this? Do you have a good strategy or solution?

We will have two different URLS and we can use cookies to achieve this if needed.

Was it helpful?

Solution

It's fairly simple and would be done the same way user's are redirected to mobile site. Implement Application_PreRequestHandlerExecute in global.asax.cs

If they fit whatever criteria you decide, Response.Redirect them. I'd store a cookie on whomever is going to stay on one site or the next so they dont erroneously get redirected while in the middle of viewing the non-beta site. This also doesn't handle the case of people not using cookies.

This is pseudo code, so it may not be 100% correct


protected void Application_PreRequestHandlerExecute(object sender, EventArgs
e)
{

if(Request.Cookies["BetaResult"] == null)
{
   var  cookie = new HttpCookie("BetaResult");
   cookie.Expires = DateTime.Now.AddDays(1d);
   if(whatever logic to redirect to beta)
   {
       cookie["BetaResult"] = "Beta";
       Response.Cookies.Add(cookie);
       Response.Redirect("your beta site");
   }
   else
   {
       cookie["BetaResult"] = "Main";
       Response.Cookies.Add(cookie);
   }

}
else
{
  //if cookie value is beta, redirect to beta site, they 'are a chosen one'
}  

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top