As i've mentioned in comments you can use IHttpActionSelector to achieve this. But instead of implementing interface directly you can inherit from default implementation.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Http.Controllers;
namespace WebApplication1
{
public class CustomHttpActionSelector : ApiControllerActionSelector
{
public override HttpActionDescriptor SelectAction(HttpControllerContext controllerContext)
{
var urlParam = HttpUtility.ParseQueryString(controllerContext.Request.RequestUri.Query);
var actionType = urlParam["actiontype"];
if (actionType == null)
return base.SelectAction(controllerContext);
MethodInfo methodInfo;
if (actionType.ToString() == "1")
methodInfo = controllerContext.ControllerDescriptor.ControllerType.GetMethod("Action1");
else
methodInfo = controllerContext.ControllerDescriptor.ControllerType.GetMethod("Action2");
return new ReflectedHttpActionDescriptor(controllerContext.ControllerDescriptor, methodInfo);
}
}
}
And to register it you need to add following line to your WebApiConfig.cs
file:
config.Services.Replace(typeof(IHttpActionSelector), new CustomHttpActionSelector());
In your controller you than add two methods Action1 and Action2:
public string Action1(string param)
{
return "123";
}
public string Action2(string param)
{
return "345";
}