Q: Can I add an action to ApiController as extension method? I am bulding a MCV4 Web API application, and I want to let the users add plug-ins to the application. It requires add actions to apicontrollers without modifying the orginal application.
I wonder if I can added the actions as extension methods, like the following code.
//controller in the original application
namespace MyApplication.Controllers
{
    public class MyController : ApiController
    {
        //some action
    }
}


//in user assembly
//user plug-in register route
config.Routes.MapHttpRoute(
                name: "userAction",
                routeTemplate: "api/{controller}/userAction/{id}",
                defaults: new { controller = "MyController", action = "userAction" },
            );


//also in user assembly
//extension method
using MyApplication.Controllers;
.........
public static class MyExtension
{
        [HttpGet]
        public static object userAction(this MyController c, int id)
        {
            return id;
        }
}

the ablove code is not working of course, the action can not be found.
Is there a wa to do something like this?

A: Web API looks for the actions in the controller type by default. An extension method is not part of the type, so it can not be found via reflection on the type. If you want a different behavior, you might need to provide a custom IActionSelector implementation. A good example of how develop a custom IActionSelector implementation is shown here, 
http://www.strathweb.com/2013/01/magical-web-api-action-selector-http-verb-and-action-name-dispatching-in-a-single-controller/
