Introduction To .NET Core 1.0 - Universitatea „Alexandru Ioan Cuza”

Introduction to .NET
Florin Olariu
“Alexandru Ioan Cuza”, University of Iași
Department of Computer Science
ASP.NET Web API - II
Agenda

Status codes recap

Demo : How to return child resources

Demo : Working with serializer settings

Content negotiation

Demo: Content negotiation

Demo : Creating a resource

Demo : Validating input

Demo : Updating a resource

Demo : Deleting a resource

Best practices in Web API’s

Summary
Status codes recap
Status codes recap
Demo : How to return child resources
Demo : Working with serializer settings
Content negotiation
Content negotiation

Formatters and Content negotiation
Content negotiation

Formatters and Content negotiation

The idea is selecting the best representation for a given response when the are
multiple representation available.
Content negotiation

Formatters and Content negotiation

The idea is selecting the best representation for a given response when the are
multiple representation available.

Pass media type via the accept header of the request
Content negotiation

Formatters and Content negotiation

The idea is selecting the best representation for a given response when the are
multiple representation available.

Pass media type via the accept header of the request

application/json

application/xml
Content negotiation
Content negotiation
Demo: Content negotiation
Demo : Creating a resource
Demo : Validating input

ModelState

Data validation

For custom validations make use of Fluent Validation

https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Core/

https://www.exceptionnotfound.net/custom-validation-in-asp-net-web-api-withfluentvalidation/
Demo : Updating a resource
Demo : Deleting a resource
One more thing…(1/2)
One more thing…(2/2)
Best practices for API’s
https://medium.com/@schneidenbach/restful-api-best-practices-andcommon-pitfalls-7a83ba3763b5#.6wmaehuhu
Summary

Recap status codes

Formatters and content negotiation

Creating/updating/deleting updating resources

Best practices
Bibliography

Pluralsight
Questions

Do you have any other questions?
Thanks!
See you next time! 