Enable Basic Authentication in WevApi
There are various ways to authenticate a request in WebApi but in this post I am going to talk about how to implement basic authentication in WebApi. The primary purpose of these authentication mechanism is to validate the incoming request. In basic authentication user credentials are hooked-up inside request and you can find it under the authorization header. If you are using third party token base services like oAuth2 to validate the request then these services are also uses the same basic authentication mechanism to validate the user before sharing the token with them. Lets get started Step 1- Create an attribute class and inherits the members of AuthorizeAttribute attribute class. The reason of inheritance is to override the “IsAuthorized” method. public class AuthorizeUser : AuthorizeAttribute { protected override bool IsAuthorized( HttpActionContext actionContext) { } ...