This post is about building another middleware component for ASP.NET 5. Long back I wrote a post about Basic authentication for Web API. This implementation uses the same functionality. It checks for Authorization header in the HTTP Request, if not found it set the Response status code to 401 and adds a WWW-Authenticate header. When browser receives such response, it will show the Basic authentication dialog. If the header is set, you can parse the header and validate the credentials against database. Here is the implementation.
And here is the code running on HTTP listener.
Happy Programming :)
Did you like this article? Share it with your friends