Here are two approaches that would not require you to have 2 separate Controller classes.
Request Headers
One of the recommended versioning designs is to use request headers instead of URL parameters.
if (Request.Headers["API Version"] == "2")
{
return Version2Code();
}
return Version1Code();
Use a RouteContraint
You could also use a route contraint too:
config.Routes.MapHttpRoute(
name: "versionedApi",
routeTemplate: "api/{version}/{controller}/{id}",
defaults: new { id = RouteParameter.Optional },
constraints: new {version = @"^[vV]\d+$"}
);
Then version would become a route function parameter just like id.
public class AccountController: Controller {
public class ActionResult Index(object id, string version)
{
if (string.Equals(version, "v2", StringComparison.OrdinalIgnoreCase))
{
return Version2Code();
}
return Version1Code();
}
}
Also, check out Web API 2 Attribute Routing
Also, if you do upgrade to Mvc 5 and WebAPI 2, there are examples of how to do this with Attribute Routing http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2