.Net Core and NancyFX: can writing a WebApi get any simpler?

Last Thursday I attended a Meetup hosted by my friends of @MsCodersMadrid in Madrid where, thanks to @snavarropino, I learned a bit about the NancyFX open source framework.

I really couldn’t believe my eyes when I saw how simple it is to use NancyFX to write a Web API. Two of the things that got my attention were: the out of the box content negotiation and zero configuration dependency injection.

What are we waiting for? Lets’s put in the mix .Net Core and NancyFX and ask ourselves: can a WebApi get any simpler?.


1. Create the application
2. Replace the contents of project.json
3. Replace the contents of Program.cs
4. Add a Startup.cs
5. Create a service to return some random message
5. Create a NancyFX module to host the WebAPI
6. Run and test the application

Get a copy of the code here: https://github.com/cmendible/dotnetcore.samples/tree/master/nancyfx.sample

Hope it helps!

7 thoughts on “.Net Core and NancyFX: can writing a WebApi get any simpler?

    1. The browsers sets the Accept header to text/html (i.e. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8) while postman sets the value to Accept: */*.

      In the first case Nancy does not know how to format the json result to html in order to return what the browser is expecting.
      In the second case postman expects anything so nancy returns the json.

      Hope it helps…

  1. I am curious if there were any discussions in the Meetup that talked about the comparison between NancyFX and .Net Core. I know that NancyFX has been aroudn for quite awhile and alot of what we see in .Net Core was adopted from NancyFX but I have not seen a comparison matrix yet.

Leave a Reply