title: Reusing route & logic for Asp.Net Core controller
body: <p>I'm just getting started with Asp.Net Core (and asp.net in general) and I'm trying to build nice controller classes for my rest api.</p>
  
  <p>I'm trying to inherit from a base controller to avoid redefining routes and logic such as validation for resources like so (non working example):</p>
  
  <pre><code>[Route("/api/v1/users/{id}")]
  public class UserController: Controller
  {
      protected int userId;
      public override void OnActionExecuting(ActionExecutingContext context)
      {
          base.OnActionExecuting(context);
          // Validate userId..
          userId = (int) RouteData.Values["id"];
      }
  
      [HttpGet]
      public IActionResult Info()
      {
          // Use this.userId here
          return this.Json("User info..");
      }
  }
  
  [Route("/friends")]
  public class UserFriendsController: UserController
  {
      [HttpGet]
      public IActionResult Info()
      {
          // Use this.userId here
          return this.Json("List of user's friends..");
      }
  }
  </code></pre>
  
  <p>I realize I can put this into a single class with multiple actions, but my real scenario involves more controllers that all may want to inherit from UserController.</p>