Using basic authentication in a Web API application
Some instructions on how to create implement basic authentication in a Web API application. Just follow what is shown in the steps and screenshots as shown: Step 1: Create a new ASP.NET Web application in Visual Studio: [caption id="attachment_8209" align="alignnone" width="826"] basic authentication in a Web API application[/caption] Step 2: Create a new authentication filter I have created a new folder with which to put any new filter classes: Create a new class called BasicAuthenticationAttribute. This needs to inherit from AuthorizationFilterAttribute. [code language="csharp"] using System; using System.Net; using System.Net.Http; using System.Security.Principal; using System.Text; using System.Threading; using System.Web.Http.Filters; namespace WebApiAuthenticate.Filters { public class BasicAuthenticationAttribute : AuthorizationFilterAttribute { public override void OnAuthorization(HttpActionContext acti...