Supporting Single Sign On In Your Nancy Applications

In enterprise application the requirement for single sign on is common: Users are already authenticated against the domain controller - they don't want to jump through another authentication hoop to get access to your particular application. Setting this up in ASP.NET using WIF is some pretty easy web.config gymnastics and described elsewhere. The result of this setup is that the current principal on authenticated requests is a ClaimsPrincipal identifying the user in terms of the claims setup for him/her in the identity provided (e.g. your organizations Active Directory).
Below I show how to integrate the WIF authentication setup with your Nancy application - It doesn't take much, but lets


Organizing Per Feature in Nancy

We've all built applications that look like this:

Typical project structure

There's a bit of a problem here. What does Exception Reporting have to do with Validation? Or the Home Page? Mostly nothing, other than these classes perform the same kind of function.

Wouldn't it be easier to organize everything by feature instead? Views, View Models, scripts, stylesheets, everything?

Better project structure

This is a cinch in Nancy. First thing you need to do is specify your own view location conventions:

protected override void ConfigureConventions(NancyConventions nancyConventions)


Blogging with Markdown & Deploying via Git - Introducing Sandra.Snow

There are many markdown blogging engines out there such as Calepin, Scriptogram and even WordPress allows you to write blog posts in Markdown but Sandra.Snow tries to add something different. Firstly, it is written in .Net and Nancy, secondly its a static blog generator and finally it supports Git deployment.

Even if you don't want to use Git deployment you can use FTP, its a great tool. To write your blog post in Markdown you need a custom header in your file so it knows some information about your post.

layout: post
category: Azure
title: Setting up a ServiceStack Service

It then parses this information along with your Markdown into its engine, uses a Markdown view engine to


The "Instant Nancy Web Development" Book

After a quick six month writing and editing process my Nancy book is published. It's available as e-pub, mobi, pfd and dead trees via the publishers site as well as Amazon, Amazon UK, and Safari.

What's it about?
Well, it about the Nancy web framework. Nancy is an awesome .NET based web framework that focuses on being both easy and fun to work with. Nancy lends itself to writing highly testable web application with simple, concise and readable code. Who doesn't want that?
The book starts from the very basics of getting Nancy up and running, but quickly moves into more interesting areas including dependency injection, hosting, content negotiation, authentication, async processing and more.


Async Route Handling with Nancy

I don't know about you but all I hear is "ASYNC ALL THE THINGS!", I think this is partly down to its new and shiny and us developers love "the shiny" and partly a lot of the things we do in our applications are I/O based whether that be database or file system.

The problem that comes with the new and shiny bandwagon is you need to understand what you're evangelising. Making asynchronous methods and executing them with no actual reason will not give your codebase any gains and could actually effect your application's performance. There is more depth to that argument but for simplicity just remember this, only use asynchronous methods if you are doing some sort of I/O.

It could also be


Getting RavenDB Profiling Working on Nancy

This is my second attempt. :)

About a year ago I made an attempt to wire Nancy together with RavenDB and failed miserably. Needed a break from businessy coding last night so I decided to work on something fun instead.

The ability to see what's going on in your application is so important when it comes to performance tuning. Yes, there's that old adage about premature optimization. IMO this phrase is taken out of context. To me 97% of the time means 97% of the code in your face, which is doing stuff in memory. The other 3% of your code is doing I/O of some sort. Minimizing the use of I/O will provide the biggest performance gains for most applications.

In fact having the profiler on here


My Nancy Talk from NDC

The video of the talk I did on Nancy at NDC is out.

The talk me writing some Nancy code, talking a lot about Nancy and at the end I have a simple todo application.



Lowering The Barrier To Entry For Testing On Linux / Mono With Vagrant

Introduction We are big fans of Mono on the Nancy project – we have Continuous Integration builds that run on both Mono 2.x, and Mono 3.x (in addition to Microsoft’s .net), and we have TravisCI also performing Mono builds of all pull requests as they come in. As good as Mono is though, there are […]


Windows 8, Hyper-V, VirtualBox, Vagrant and Hanging on Boot

¬†Introduction I’ve recently been playing around with Vagrant¬†to allow Nancy contributors to easily test their changes on Mono, even if they don’t have much (or any) experience with Linux or Mono itself (more on this soon). Vagrant allows scripts to be created to quickly and easily spin up virtuals with a certain configuration, and just […]


Automatic Exception Reporting with YouTrack and Nancy pt. 2: Bouncing Off the Green Monster

In Part 1 of this series we looked at putting NancyFX as a simple http wrapper in front of YouTrack. Now we're going to make it more RESTful - i.e. we will display the error page to the user agent and include the exception report form on that page.

We will do this by leveraging Nancy's status code handling features. This will allow us to intercept any status code we want and modify the response. Let's start with the view to collect the bug report:

@inherits NancyRazorViewBase<Nancy.Extras.ExceptionReporting.ViewModels.ReportExceptionViewModel>
<!DOCTYPE html>
<!-- Views/50x.cshtml -->