Category Archives: Web API

HTTP status codes

HTTP(Hypertext Transfer Protocol) status codes are standard response codes given by Web API’s on the Internet. Here, below the list of status codes: 1×× Informational:- 100 Continue 101 Switching Protocols 102 Processing 2×× Success:- 200 OK 201 Created 202 Accepted 203 Non-authoritative Information 204 No Content 205 Reset Content 206 Partial Content 207 Multi-Status 208… Read More »

API Versioning in ASP.net Core

ASP.NET API versioning gives you the ability to improve and iterate on API’s without breaking contracts. At times the stagnation of innovation on an API is simply because of legacy decisions that cannot be reversed, especially on public API’s. But versioning can quickly get out of control, especially with custom implementations. The API versioning extensions… Read More »

Global Exception Handling in ASP.NET Core WEB API

In my previous post, i have used multiple ways (Exception filter, Global.asax, OnException at Controller etc.,) to implement exception handling in Asp.Net MVC. Asp.Net Core comes with many in-built and ready to use middleware, and you can add them to your application in the Startup class Configure method. One of the in-bulit ASP.NET Core diagnostic… Read More »

Failed to serialize the response in Web API

Simplest example of this, I get a collection and try to output it via Web API: // GET api/items public IEnumerable<Item> Get() { return MyContext.Items.ToList(); } And I am  getting the below error while hitting the api via Postman: This is a pretty common error to do with the new proxies, and I know that… Read More »

IHttpActionResult vs HttpResponseMessage

In this post, we will learn the difference between IHttpActionResult and HttpResponseMessage, advantages of using the IHttpActionResult, why should we use IHttpActionResult instead of HttpResponseMessage and predefined helper methods for IHttpActionResult with examples. In web Api 1, We have a type called HttpResponseMessage for returning Http response message from action method. It is easy to use… Read More »

Implementing Basic Authentication in ASP NET Web API

In this post, we will learn to how to implement basic authentication using custom authentication filter. We will not go with  any membership technique like asp.net identity. In my previous post i have explained to implement Authentication and Authorization in Asp.Net MVC using IPrincipal interface, AuthorizeAttribute, Filters and session. But in this post i will use… Read More »

Token Based Authentication using ASP.NET Web API 2, Owin, and Identity

As I stated before we’ll use token based approach to implement authentication between the front-end application and the back-end API, as we all know the common and old way to implement authentication is the cookie-based approach were the cookie is sent with each request from the client to the server, and on the server it is… Read More »