> ## Content Index
> Fetch the complete content index at: https://www.mrstebo.co.uk/llms.txt
> Use this file to discover other available public pages before exploring further.

# Lets Play With Nancy!
- URL: https://www.mrstebo.co.uk/lets-play-with-nancy/
- Published: 2015-06-01T23:00:00.000Z
- Updated: 2023-05-15T23:43:33.000Z
- Author: Steven Atkinson
- Tags: Software Development, Software Engineering, Dotnet, NancyFX, API

I have just discovered Nancy when I was trying to find a way to decouple the MVC element from my ASP.NET applications. I knew there had to be a way! It is very easy to decouple your Web API stuff using the readily available Owin packages ( [Microsoft.AspNet.WebApi.Owin](https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin/?ref=mrstebo.co.uk)).

# How easy is it to set up?

****It’s bloomin’ easy!** I managed to get some simple output with only 2 files! Which is great, considering the default MVC scaffold has a whole lot of files.

# Where do I begin?

So you’re ready? Okay, lets play with Nancy! 😀

You will need to run these 2 commands from the ****Package Manager Console**:

- Install-Package [Microsoft.Owin.Host.SystemWeb](https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/?ref=mrstebo.co.uk)
- Install-Package [Nancy.Owin](https://www.nuget.org/packages/Nancy.Owin/?ref=mrstebo.co.uk)

![](https://miro.medium.com/v2/resize:fit:227/0*rrG7WWhdpikkbAkW.png)

Alternatively you can use the “Manage Nuget Packages” option when you right click on the “References” item on the solution explorer.

Next we need to add a Startup file, which is the entry point for an Owin web application.  
The great thing is that it only takes a few lines of code 🙂

# Nancy Modules

Modules are just like the Controllers of a standard MVC web application. Although there is ****one major difference**. Unlike with a standard MVC app, you will have to define your methods and routes manually from within the module. For people who have been using [Attribute Routing](http://blogs.msdn.com/b/webdev/archive/2013/10/17/attribute-routing-in-asp-net-mvc-5.aspx?ref=mrstebo.co.uk) this should feel quite normal.

I guess it is time to show you how simple this actually is!

This will just print Hello, World on to the / route.

# What did I tell you?!

Two files, and we already have a functional MVC application.

# Whats next?

There is a lot more stuff that Nancy can do. And I will write another article soon on its additional features, such as model validation, and being able to use Razor views with your routes.