Meet Nancy

Meet Nancy

The first thing that comes up to mind with the name Nancy, is Frank Sinatra's first child. However, Nancy recently has been associated with another big name: Framework.

Nancy is a lightweight, low-ceremony, framework for building HTTP based services on .NET and Mono.

The inspiration for the creation of NancyFx is the Sinatra framework for Ruby. Nancy is designed to handle HTTP requests (GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS) easier and quicker than you can even imagine. With NancyFx you can create a simple Web API within 15 minutes, without spending days and days to create a startup project.

From Zero to Hero

To start creating your API with Nancy, the first thing you need to do is just to create the Empty .NET Project and to select the Web API checkbox.

Starter project

One last thing that you need to do before you begin, is to install Nancy packages. Right-click on your packages folder -> Add Packages… and any Nuget package that you need for your project will now be available. Nancy is so simple, that you need to add only two packages in order to start running your API. If you type "Nancy" in the search bar, a bunch of Nancy packages will be shown. You need to add only two (see the image below) and you are ready to go.

Nancy Packages

After this step, you can start coding. Create Empty C# Class, which extends from NancyModule. Then, create few routes in the constructor of this class. Now, you can feel the magic of Nancy. In the image below you can see my two dummy routes.


And that's it. You can now run your app and get a functional Web API with two routes. If you type "localhost:8080" on your browser string, a "Hello World" phrase will be shown. Finally, "localhost:8080/show-html" will bring you a dummy HTML, as shown in the image.

Final result