static void

ASP.Net Core Controllers

Up to 4.6, MVC used a "Controller" base class while WebApi had an "ApiController" base class. For Core, MVC and Api have a single base class, "Controller" (and they can use POCO controllers, with no base class).

Dependency Injection

Poco controllers

You don't have to inherit from Controller (which are in Microsoft.AspNetCore.Mvc.ViewFeatures, not Microsoft.AspNetCore.Mvc.Core), but pocos probably need extra information to be injected.

Poco controllers get property injection for 3 properties: ActionContext (which gives you HttpContext), ViewData (ViewDataDictionary) and Url (IUrlHelper). At which point, you might as well inherit from controller.

public class MyPocoController
    public ActionContext ActionContext { getset; }

    public string Get()
        var user = ActionContext.HttpContext.User;
        if (user.HasClaim("Role""Admin"))


Ideally return IActionResult (in MVC 5 we used ActionResult - you can still return a string or model).

WebApi routing

MVC5 automagically mapped HTTP verbs to action names (Get, Post). Now we have to use explicit [HttpGet] and [HttpPost] attributes (and mapping with attributes seems to be preferred generally)

Partial (Child) Actions - use ViewComponents

You cannot use MVC 5 partial actions - @Html.Action / [ChildActionOnly] / return PartialView

Use viewcomponents instead: @Component.Invoke("name",model) / component inherits from ViewComponent and implements Invoke(args)