VQ Communications Funds NancyFX to run on CoreCLR

Nearly 2 years ago I was employed by VQ Communications primarily because of my open source contributions to NancyFX. They had started work on a v2 of their flagship product and had begun work with Nancy and needed someone to help drive a HTTP API and architect a scaling solution as their v2 product was addressing a requirement they had for it cope with large volumes of traffic. Also of interest to me was their aim to deliver all of this as a black box appliance to customers on a VM running a custom embedded version of Linux using Postgres as the database. I would work four days a week remotely and go into the office one day a week. They already had completely remote employees and since I have been there they have taken on more. There are lots more juicy technical examples in the stack I could go into however, this is not the point of this post.

Read more...

Profiling a CoreCLR application with dotMemory

I had ported an application over to CoreCLR (that’s a whole other blog post), along with my colleague James Humphries put it in a docker image and sat back and watched it do its thing. After 6 hours of running the docker container had crashed. Ah nuts we thought, so pulled up the logs from docker and the last line looked like this 2016-02-10T20:18:31.728783069Z Killed. I’m pretty sure when you have a log entry with Killed in it, things can’t be good. To the interweb…

I opened up the CoreFX repository on Github to search for the term Killed and there were 2 comments but nothing that was logged out anywhere. I then Googled for docker and killed and there was an entry that someone else had spotted on their container and the feedback was essentially it was probably out of memory.

Read more...

Introducing Negotiator - a GoLang content negotiation library

In my continued experience learning GoLang I started looking at how to best use it when dealing with HTTP. The idiomatic way to use GoLang and HTTP is to use the standard library which keeps things minimal but there are a few features missing. The first thing is a router. OOTB GoLang doesn’t have a router and the majority seem to suggest using a package called Mux from Gorilla Toolkit, a set of libraries that aims to improve the standard library from Go. After having a play with it I didn’t really warm to it so spent some time looking into the alternatives (and there are plenty!) and eventually decided upon Goji

Once I had started using Goji I then wanted to handle content negotiation in my HTTP handler. As I said earlier GoLang is minimal in its offerings OOTB and this is a good thing. Just for the record there are a few frameworks out there if you want/need and all encompassing framework such as Martini, Revel and Echo. These tend to bend the idioms of GoLang a bit and even the author of Martini blogged on this fact due to feedback from the community that although its capabilities are great they aren’t idiomatic Go.

Read more...

Introducing PoGo - a GoLang, Twitter favourites to Pocket importer

I’ve always kept myself up to date with the latest languages arriving on the scene and I’ve spent time in the past learning Node and last year I learnt Python by doing the Omnisharp plugin for Sublime. I have recently been looking for a static language that I can transfer my C# skills too and I had narrowed it down to 3; Swift, Kotlin and GoLang. I started out with Kotlin and setting up a dev environment with IntelliJ and running the koans that Jetbrains advise you step through to pick up the language. Whilst it seemed relatively straightforward I got “noob confused” when I saw examples of Java calling into Kotlin with get/set prefixes somehow magically added to Kotlin properties. It turns out the Kotlin compiler does this for Java libraries so it can communicate with it, to me it seemed strange that I code a library in one language and the compiler then exposes these methods and properties slightly differently. Superficial as this sounds I also didn’t really like the mammoth that appears to be IntelliJ. Coming from a predominantly Visual Studio background but working with Omnisharp I wanted a lightweight editor with some refactoring, intellisense and error highlighting.

Read more...

NancyFX and Hypermedia

I’ve been slowly educating my self on hypermedia; what it is, how does it help and how to use it. I must say I’ve found it a very interesting topic and I thought it was time I put some information into a blog post just in case the 2 people that read this blog might find it useful.

In my day job I’m responsible for a HTTP API (notice I didn’t use REST) and some months ago I spoke to Glenn Block around a general discussion about hypermedia. Glenn put this on YouTube if you want to watch it.

Read more...

Cookie Authentication & CRSF with AngularJs, Owin & Mono

I’m currently working on a project that has Nancy serving up an API. For the UI there is AngularJS. We were using JWT for authentication just to get us up and running but then as things became more final in the product we knew it would be better to swap to cookies for security plus we may as well leverage the browser capabilities for cookie handling. I’m not going to get into the arguments about JWT security vs cookie security, there are advantages/disadvantages for using both in this scenario. Our API is built on top of OWIN and Microsoft provide cookie middleware so I thought this would be nice and simple to plug in. Lets just remember I’m working on Mono!

In our Startup class I added the below

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationMode = AuthenticationMode.Active,
    CookieHttpOnly = true,
    CookieSecure = Microsoft.Owin.Security.Cookies.CookieSecureOption.SameAsRequest,
    SlidingExpiration = true,
    AuthenticationType = "MyCookie",
    CookieName = "MyCookie"
});

Hopefully thats pretty self explanatory. So I fired up my application and BOOM!

Read more...

Running Gulp in Visual & Xamarin Studio

I was going to write a long post explaining about all the pain I went through to get this working but then realised you probably don’t really care and you just want the code!

Show the code

Read more...

Microsoft Endorsing C# as a First Class Citizen in Sublime Text

At the end of my last post on using ASP.Net vNext with Sublime Text I briefly mentioned a plugin that aimed at giving intellisense for C# within the editor. Well 2 months later and I’m happy to announce that intellisense works and I’ve added a slew of other features that will hopefully make you feel at home away from Visual Studio.

I discovered the plugin thanks to Jason Imison but at that point there was some issues getting the intellisense working consistently because at that time I was using it with an ASP.NET vNext application which didn’t have a solution file (*.sln) and the plugin was expecting that. After speaking to Jason I found out I could change the settings so it wouldn’t expect a solution file and give me the intellisense I was after in a text editor. Eureka, it worked! I was now on a mission to make Sublime be a first class citizen when writing C#. Some may question why on earth would I want to edit C# in something other than Visual Studio. I don’t really want to get into that debate here but all I’ll say is, it’s nice to have other editor options and with Microsoft’s mission to provide vNext compatibility with Mono and Visual Studio not running on OSX/Linux it makes sense to have an editor with feature rich C# support (yes I know there is Xamarin Studio but “options” people, “options”).

Read more...

Nancy, ASP.Net vNext, OSX and Sublime Text

One of the great things that ASP.Net vNext is bringing is the ability to use it cross platform with Microsoft actively testing their libraries against Mono. Along with this MS are developing a web server that is cross platform and goes by the name of Kestrel. One thing they aren’t doing, yet, is making Visual Studio cross platform so we need something to write our code in. There a few editors out there but one of the most common is Sublime Text. This gives you syntax highlighting and build systems that can all be configured so if you are not aware of it check it out. Obviously before we can start writing code on OSX with our editor we need Mono installed.

UPDATE - As of August 13th 2014 there is a Mono 3.6 release which means you no longer need to compile Mono but you will need to install Homebrew for ASP.Net vNext. Skip to nnext section

At the time of writing the official binary for Mono is 3.4.0 and this does not include some features needed for ASP.Net vNext to run so we are going to have to manually compile Mono ourselves. Now I know this sounds scary but its not as bad as it seems and I’ve gone through the pain of setting it up so hopefully this blog post should make it easier for you

There is a guide on Mono’s website on how to compile but I found some issues with it. I’m running on OSX Mavericks so I’m not sure if that resulted in issues but here’s my guide to get it compiling.

Read more...

Nancy, ASP.Net vNext, VS2014 & Azure

By now we know of Microsoft’s plans for the next version of ASP.Net and they’ve turned it on its head and from the looks of it, its goooooood!

Here is a blog post from Scott Hanselman introducing ASP.Net vNext. There are introductory and deep dive videos available for your perusal which are also well worth a watch.

The TL;DR is ASP.Net vNext will take heavy influence from Node.js by using Owin to wire up all the app dependencies and middleware. It will also remove *.csproj files and use a project.json file similar to Node’s package.json and use NuGet to reference the application’s dependencies. It also takes inspiration from Node and Nancy’s approach requiring you to opt-in to dependencies rather that traditionally having everything but the kitchen sink. It also takes influence from Nancy via built in dependency injection and Mono support. Microsoft announced they will run all their vNext tests against Mono builds ensuring all their code is compatible for cross platform deployments.

Here’s a tweet direct from the horses mouth albeit with a typo .

vNext influenced by Node/Nancy

Read more...