Thursday 16 February 2017

Should you use Nancyfx for your ASP.Net Applications?


In June, Microsoft announced ASP.NET Core 1.0 with a number of architectural changes. In addition to being cross-platform, the completely redesigned edition of ASP.NET further simplifies development of modern web applications and services by providing a set of new tooling and features like side-by-side app versioning support, built-in dependency injection support, and Cloud-ready configuration. Also, it allows you develop both Web UIs and Web APIs by using a single aligned web stack.
You still have option to use additional tools to build HTTP based services without putting extra time and effort. Nancyfx is a lightweight and open source framework, inspired by Sinatra - a widely used Ruby framework, and designed with features to facilitate development of HTTP based services on both .NET and Mono. Despite being built with .NET framework client profile, Nancyfx is designed to run anywhere, be easy to configure, and provide a super-duper-happy-path to various interactions. You can always consider using Nancyfx to enhance the functionality and performance of ASP.NET applications.
10 Reasons Why You Should Consider Using Nancyfx for ASP.NET Applications
1) No Need to Apply MVC Pattern
You can use Nancyfx for web applications, web services and web APIs. But Nancyfx does not require you to implement model-view-controller (MVC) pattern. You can use it as a service end point to handle varying requests like GET, HEAD, DELETE, PUT, PATCH, POST and OPTIONS. Also, you can take advantage of the domain specific language (DSL) to return a response without writing additional code. However, you still have option to apply MVC pattern to Nancy in a manner similar to ASP.NET MVC.
2) Supports for .NET and Mono
As noted earlier, Nancyfx is designed with features to simplify development of HTTP based services on both .NET and Mono. Hence, you can run the lightweight framework on three major platforms – Windows, Linux and OS X. The compatibility further complements the cross-platform web application developed with ASP.NET Core 1.0. Also, you can post the HTTP services from one platform to another without any hassle.
3) Compatible with Embedded Devices
The efficient machine to machine communication enabled by Internet of Things (IoT) has made it essential for developers to build web applications and APIs compatible with a variety of devices. In addition to supporting .NET and Mono, Nancyfx is also compatible with embedded devices like Raspberry Pi and Arduino. Also, the host-agnostic nature of the framework enables you to run it in number of ways – run it through IIS, integrate it with a self hosted application, or embed within an EXE. Hence, Nancyfx, unlike other full-blown web servers, can be used efficiently in constrained environments and with embedded devices.
4) Minimal Configuration
You can download and use Nancyfx directly without worrying about complex configurations. There is no need to scan through the preset configuration or make changes to complex XML files. Also, the self-agnostic nature of Nancyfx enables you to run it in varying environments without modifying the web.config file frequently. Despite being lightweight, Nancyfx is designed with features to identify and embed new modules, dependency and components, and change the configuration according.
5) Highly Customizable and Extensible
In addition to being easy to configure, Nancyfx is both customizable and extensible. You have option to replace specific parts of the framework according to the requirements of individual ASP.NET applications. You can further customize Nancyfx by using custom view renderers, serializers or model binders. Also, you can control the way the framework handles requests by implementing INancyEngine in your own way. You also have option to create 3rd party library with extensibility points generated by modifying behavior of Nancyfx.
6) Keep Your Application Code Clean
The terse syntax provided by Nancyfx will help to keep the code clean and organized by allowing you to write code without affecting any aspect of the application. Also, the low ceremony feature of the framework will enable you to include minimal code in the application. You can even take advantage of the terse syntax and low ceremony features to embed functional Nancyfx applications into simple and lightweight web applications and APIs.
7) Option to Modify Requests and Responses
Nancyfx allows you to make changes to both requests and responses before and after invocation. You can take advantage of pipeline hooks to control the entire communication between the web application and the server. The feature allows you to make the web application deliver personalized experience saving key session information of users in the database. Likewise, you can also use the pipeline hooks to modify the way request.form is populated on HTTP POST.
8) Library to Test Request/Response Cycles Fully
ASP.Net web developers can take advantage of the built-in testing library included in Nancyfx to evaluate request and response cycles fully. You can use the library to check if a request returns the expected model or not. Likewise, you can use the testing library to check if the response adheres to expected format each time accept headers are passed into it.
9) Find and Manage Dependency Automatically
Nancyfx makes it easier for you to find and manage project dependencies automatically through a built-in IOC container called TinyIOC. You also have option to use TinyIOC t different places in application lifecycle through the Bootstrapper class. The methods and properties off the Bootstrapper class further simplifies Nancyfx configuration. However, you still have option to register and manage project dependencies by using several widely used IOC containers supported by Nancyfx.
10) No Need for Specific Framework or Implementation
Often ASP.NET micro-frameworks require web developers to stick to specific frameworks or implementation. But you can use Nancyfx without any using any specific frameworks or implementation. Also, Nancyfx allows you to avail a wide range of plug-ins with additional and alternative functionality. The framework further builds requests and responses from the scratch, while keeping each request or response loosely coupled. Hence, you can easily customize Nancyfx and its components according to specific needs of each ASP.NET application.
Nancyfx is developed as an open source framework by the community, and distributed under the MIT license. You have option to download it from various sources, and access its source code without any restriction. Hence, you can easily customize Nancyfx according to the nature and requirements of each ASP.NET application.