How to use Nancy in ASP.Net Core

Take advantage of the lightweight and fast Nancy framework for building HTTP-based services in .Net Core

Nancy is a lightweight framework for building HTTP-based services. Nancy prefers conventions over configuration and provides support for GET, HEAD, POST, PUT, DELETE, and PATCH operations. Nancy is also open source under the MIT license. This article presents a discussion of how we can use Nancy with an ASP.Net Core application.

Nancy is a web framework and has no dependencies on System.Web or other .Net libraries. Most importantly, you are not constrained to adhering to the MVC pattern or any other pattern if you are using Nancy. Nancy is just a service endpoint that can respond to HTTP verbs. This makes Nancy a good choice for building websites, APIs, and web services.

Nancy is host-agnostic. You can run it in IIS, in WCF, as a Windows Service, embedded within an .exe file, or inside a self-hosted application. Nancy is quite easy to set up and customize. Another advantage of Nancy is its built-in support for dependency injection. Nancy also provides a library that can be used for testing the request-response cycle easily. I’ll discuss this feature of Nancy in a later post.

Create an ASP.Net Core project in Visual Studio

First off, let’s create an ASP.Net Core project in Visual Studio. If you don’t have Visual Studio 2019 installed in your system, you can download it here

To create a new ASP.Net Core project in Visual Studio 2019, follow the steps given below.

To continue reading this article register now