ASP.NET Web API is a framework which is used for building HTTP based services which can be accessed on different platforms such as web, windows, mobile etc.
It works nearly the same way as ASP.NET MVC web application. Difference is that Web API sends data as a response while MVC application sends html view. Web API is like a web service or WCF service but it only supports HTTP protocol.
Authentication is used to know the identity of the user. For example, any user logs in with username and password, and the server uses the password to authenticate user.
Authorization will come after authentication. In authentication we need to decide whether a user is allowed to perform an action or not. For example, User has permission to get a resource but not create a resource.
Versioning helps us to provide specific information to specific user. Now a days multiple users are consuming Web API at a time so whenever the business requirement gets changed we need to update the Web API which will work for specific user without affecting the existing users. In order to hand such situations we need Versioning.
1. URI based Versioning
In this method, with help of routing Web API URI gets changed and make it more readable. Example: we have an existing running API which is returning same response for all clients. Now if any one client wants some changes by requesting some parameters then with versioning we can achieve it without breaking any existing API.
2. Query String based Versioning
In this method a query string parameter is added to the query string in order to find the controller or Action to which request is sent. So different parameters will find different action or controller which helps in versioning.
3. Custom Header parameter based Versioning
Custom Headers are used for troubleshooting, providing additional information and implementing server-side logic, etc. Version information can be send in the custom header and check its value and return the response according to its value.
4. Accept Header parameter based Versioning
Accepts Headers requests the server and asks for the file format of the data which is required by the browser. Data is defined as MIME Types which stands for “Multipurpose Internet Mail Exchange”. MIME type is generally case-insensitive, but it is generally written in small letters.
Learn more – Authentication and Authorization in ASP.NET Web API
Author – Sahil Joshi