When Microsoft released Asp.Net Core MVC it also released the
API version which is Asp.Net Core Web API. Asp.Net Core Web API is used to
create restful services which can be used to create HTTP services which don’t
have a View layer but have Controllers and Models, they process incoming
requests and responds with data in JSON format.
Since Asp.Net Core Web API does not have a view layer, it also does not have the Razor view engine it returns the data in JSON format to other UI layer applications like Angular / Reach which will handle the UI rendering.
Since Asp.Net Core Web API does not have a view layer, it also does not have the Razor view engine it returns the data in JSON format to other UI layer applications like Angular / Reach which will handle the UI rendering.
Asp.Net Core Web APIs support GET, POST, PUT and DELETE operations to perform Select, Insert, Update and Delete operations respectively. To perform any of these operations the Action method should use the appropriate attribute HttpGet, HttpPost, HttpPut and HttpDelete
public class CountryController : ControllerBase
{
[HttpGet]
public async
Task>> Get()
{
}
[HttpPost]
public void Create(Country
country)
{
}
[HttpPut]
public void Update(Country
country)
{
}
[HttpDelete]
public void Delete(int countryId)
{
}
}
In the following posts we shall see in details on how each of these operations work.
No comments:
Post a Comment