Posts

Showing posts with the label ApiController

ApiController attribute in ASP NET Core 2.1

ApiController attribute in ASP NET Core 2.1 ASP NET Core 2.1 brings a set a enhacements for Web API development, Web API being a service accessible via HTTP and returning result in Json format. Those enhancements aim to simplify the composition of those APIs and also remove unecessary functionalities. Today we will explore those enhancements in five parts ControllerBase and ApiController Automatic model validation Inferred model binding ActionResult<T> 1. ControllerBase and ApiController Prior everything, we should set the compatibility version of ASP NET Core by using the .SetCompatibilityVersion . services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); In the past, we used to inherit from Controller which was providing functions to return different HTTP status code results together with optional data like Ok(...) or Json(...) , but it was also used to display Razor views like View(...) or PartialView(...) . Starting from 2.1, it is now recomm...