Nancy Is Cool
29 March, 2014I recently used Nancy to implement a new add-on to an existing Web Forms app. With Nancy on the backend and a some helpful front-end libs, the new implementation was quick, simple and flexible. It was a success, largely due to the development story Nancy provided.
Web Forms, HTTP Modules, and One ASP.NET
I initially wanted to implement with the existing code, afterall Web Forms is a powerful framework. However, its strengths and opinions are not exactly compatible with persistent single pages and asynchronous HTTP communication. This code base was one of many engineering efforts I've seen that coerce Web Forms into something that provides the feel of a single-page app . There was certainly some rough edges to work around, more importantly, I needed more control of the client pages asynchronous behavior than what was available.
I considered implementing an ASP.NET HTTP Handler. Sounds reasonable, but I didn't want to go without model binding, URL routing, and server side HTML templates. I also didn't have the time to thrash about wiring that up. Using an existing framework would make for a quicker cleaner implementation.
I thought about integrating ASP.NET MVC or Web API. Unfortunately, I didn't have access to the latest framework features or tooling that supports One ASP.NET. I really didn't want to spend time hacking on configuration files or trouble shooting odd inconsistencies of an ultimately unsupported development story within ASP.NET. I really needed a framework that would just allow me to execute.
Hello Nancy
Nancy is a small web framework that sticks close to HTTP. It allowed me to
implement a robust HTTP backend with very little code. It has been built from
the ground up to run anywhere. It doesn't carry the framework dependencies
that Web Forms, ASP.NET MVC, or Web API share. Nor does it impose on existing
ASP.NET applications. Yet, by using the Nancy.Hosting.Aspnet
NuGet, I was
able to quickly write the new module side-by-side with the existing code base.
This even allowed me to leverage the existing application's Web Forms security
context.
Conclusion
Each ASP.NET technology has its utility. Nancy is a great option for a variety of projects. However, here it excelled as the quickest path to delivery, while extending a long existing web application.