• X-Http-Method-Override with NancyFX posted on 11 Feb 2013

    Forms in HTML only allow you to use the method's POST and GET, I'm not sure if this would be classified as a limitation or not, but it does introduce a slight problem when you want to create a nice API taking advantage of verbs such as PUT and DELETE, when you can only POST and GET.

    This means if you want to delete something you have to use a different URL, like:

    /products/123/delete

    Then define a route like

    Post["/products/{id}/delete"] = _ =>
    {
        ... Do Something...
    };
    

    This isn't exactly ideal, what we would prefer to have is a more semantic route.

    • GET -> gets an object
    • DELETE -> deletes an object
    • PUT -> modifies an object
    • PATCH -> modifies part of an object
    • POST -> creates an object

    Note: I'm no expert on this stuff so the VERBs above may not be correct wording.

    This would allow us to define the same route like so

    Delete["/products/{id}"] = _ =>
    {
        ... Do Something...
    };
    

    Read more...

  • OAuth with ASP.NET MVC and WorldDomination.Web.Authentication posted on 05 Feb 2013

    This post is a follow on from my previous post OAuth with NancyFX and WorldDomination.Web.Authentication except this demonstrates how you can use WorldDomination.Web.Authentication with ASP.NET MVC, writing only minimal code in the process.

    To save you jumping to the other post, I'll quote myself:

    One of the biggest pains of building websites, in my opinion, is implementing OAuth providers, it's often fiddly, doesn't work, and frameworks that are created to try make things easier, don't seem to make it easier.

    So PureKrome and myself decided to create WorldDomination: Web Authentication

    The idea behind this framework is to keep it super simple to implement OAuth into your website, without the bloat. The core framework ONLY deals with Google, Twitter, and Facebook authentication. It doesn't try to create a fancy UI for you, it doesn't require you to write lots and lots of code. You simply give it some info, it redirects, it comes back and gives you the authentication info.

    So without further adieu...

    Installing

    Installing the library for MVC requires installing the MVC specific library.

    PM> Install-Package WorldDomination.Web.Authentication.Mvc

    This will install:

    • WorldDomination.Web.Authentication.Mvc
    • WorldDomination.Web.Authentication
    • RestSharp

    Read more...

  • OAuth with NancyFX and WorldDomination.Web.Authentication posted on 31 Jan 2013

    One of the biggest pains of building websites, in my opinion, is implementing OAuth providers, it's often fiddly, doesn't work, and frameworks that are created to try make things easier, don't seem to make it easier.

    So PureKrome and myself decided to create WorldDomination: Web Authentication

    The idea behind this framework is to keep it super simple to implement OAuth into your website, without the bloat. The core framework ONLY deals with Google, Twitter, and Facebook authentication. It doesn't try to create a fancy UI for you, it doesn't require you to write lots and lots of code. You simply give it some info, it redirects, it comes back and gives you the authentication info.

    Just recently the guys contributing to JabbR decided to use the library, and with feedback we added some really awesome support for NancyFX which I will show.

    Installing

    Installing the libary for Nancy requires installing the Nancy specific library.

    PM> Install-Package Nancy.Authentication.WorldDomination

    This will install:

    • Nancy.Authentication.WorldDomination
    • WorldDomination.Web.Authentication
    • RestSharp

    Read more...

  • Introducing Raygun.io and Nancy.Raygun posted on 29 Jan 2013

    So not long ago I posted about an up and coming service from http://www.mindscapehq.com called Raygun, well last week they went into beta, and I was invited, so since early last week I've been giving their system the run around and provided a little bit of feedback.

    I say a little bit, because besides being a super early beta tester, and a super early product that will grow over time, the beta is quite polished. There was only a few minor issues which they corrected within a day or less.

    Raygun is super easy to setup and implement into your application, in-fact it's really nothing more than creating an app, install the nuget package, and set the key, and away you go.

    There's a simple guide over http://www.pieterg.com/2013/1/raygunio-has-launched, so I won't bore you with the same content.

    Nancy.Raygun

    Currently the offical Nuget package has a dependency on System.Web which isn't very nice for Nancy, so I've created Nancy.Raygun

    It has no dependency on System.Web, and uses the NancyContext rather than HttpContext.Current, it also implements IApplicationStartup so that it automatically wires itself up for handling errors for you.

    Nancy.Raygun is on Github, installing the nuget package will add the web.config for you so all you need to do is add the key and away you go.

    Why Raygun?

    I've had a few people ask me why I would use Raygun over ELMAH, or AppFail.

    Read more...

  • Introducing Sandra.SimpleValidation - Validation reinvented... again posted on 25 Jan 2013

    Yup, I decided to reinvent the wheel, don't hate on me :)

    So I grew a little fustrated, theres quite a few serverside validation libraries around, but I feel they do too much, are hard to test, yada yada yada...

    So I came up with Sandra.SimpleValidation

    The idea is that it's dead simple, it requires 0 up front configuration, it doesn't allow you to inject stuff into the validators, validators are newed up once and only once, there's no client-side validation.

    I don't believe validation should allow you to do things like inject a repository and query the database, those begin to become Business Rules and should be handled seperately. All it does is validate a model you give it.

    So what do you need to do?

    PM> Install-Package Sandra.SimpleValidator

    First up, install the package. It requires 4.0 or above, it could probably work on 3.5 but who uses that anymore?

    Read more...

  • Windows Store App with Caliburn.Micro - Basic Databinding posted on 17 Jan 2013

    Continuing on with the SampleProject for a Windows Store App, we will look at binding, this is where we will finally make use of the ViewModel.

    In the previous example we output the text 'Hello World' to the screen, but rather than put it on the screen directly we can load it when we load the view.

    First we need to create a ViewModel, Caliburn works on a naming convention so if your view is named MainView, your view model needs to be naned MainViewModel.

    In our class we want to inherit from Screen, this is a Caliburn class that is used to represent a single screen, your application may have many screens but for now we are only dealing with a single screen.

    using Caliburn.Micro;
    
    namespace SampleProject.ViewModels
    {
        public class MainViewModel : Screen
        {
        }
    }
    

    Read more...

  • IT-Communities like Hacker News are full of assholes posted on 14 Jan 2013

    I only found out about hacker news maybe... 6 months ago? This place is like 4chan for the IT-Community, and it's not the only place. The entire internet is full of assholes.

    Filip Ekberg wrote an opinionated blog post a few days ago, about how he thinks C# is the past, present and future. After self promotion on Hacker News, I'm sure a lot of people do, such as myself. He got an out pour of comments.

    "I am a Software Engineer working with various techniques such as C#, WPF, WCF, ASP.NET MVC, ASP.NET and much more"
    "I spend most of my days working with the latest technologies from Microsoft."
    "In the darkest alley-ways we still have the people not wanting to touch C# with a pitch-fork because it's behind Microsoft"
    In my opinion he lacks enough neutrality to make that statements(how he know MS tech is so great if he is totally ignorant of other options?).
    Instead of telling people to learn only Microsoft tech he could take his own advise and learn non Microsoft tech too. The world is much bigger than a single company.
    In my work as a software engineer I had to use what was good for my company, not what was good for Microsoft, Apple, or any religion(GNU or whatever).
    I had to use Java, C#, objective C, python, (and lisp and c and c++). We will never be in the hands of a single company ever.

    Read more...

  • Using publish to deploy Azure Cloud Service posted on 10 Jan 2013

    In my previous post I created an Azure Cloud Service from scratch and deployed it, however I manually logged into Azure Portal and uploaded the packages.

    @cloudnick commented saying that I could that you can use publish directly from Visual Studio. So!

    Publishing from Visual Studio directly to Azure

    Using the exact same setup as yesterday, rightclick the MyWorker project and select Publish.

    Select Sign in to download crentials

    This will take you to a webpage where you can sign into your Windows Live account that has your Azure Subscriptions, with some instructions. The file will download automatically.

    Read more...

  • Azure - Creating an Azure Cloud Service posted on 08 Jan 2013

    I've been investigating setting up a Worker Role to do something similar to a Windows Service and it seems that the Worker Role is best suited for this purpose.

    You might create a Worker Role to Poll a Message Queue, or process some data in a database, or scrape some data and persist it, etc. I'm going to throw some data in http://www.ravenhq.com every minute, for this blog post, nothing exciting, but demonstrates how to create a WorkerRole and get it up and running on Azure.

    I suspect that you could use NancyFX Self-Hosting here and host a basic Nancy website, that would be cool :)

    Building the Service (Worker / Role)

    If you haven't already you will need to install the Azure SDK, so head on over to http://www.windowsazure.com/en-us/develop/net/ and click "Install SDK" which will give you the option for 2012 or 2010. I picked 2012 because I don't know what 2010 is, I stopped living in the past.

    The installer actually uses Web Platform Installer, not sure if there's any other way to install it.

    Read more...

  • Windows Store App - Tiled Background using Mindscape Metro Elements posted on 03 Jan 2013

    Apparently WinRT XAML lacks the ability to tile a background image, and surfing the net seems to come to the conclusion that the only way is to just create a large tiled image in photoshop...

    I want to pick a Tile image from http://subtlepatterns.com/ and just use it, but I can't. So I tried photoshop... (creating a benehoth of an image that is) I tried that, and it... crashed the Simulator, over and over... So I flagged it, instead I decided to put in a feature request over at Mindscape for their Metro Elements:

    http://www.mindscapehq.com/thinktank/suggestion/505262

    I asked them to include a TiledBackground, and they delivered!

    Currently in the nightly build is the makings of a TiledBackground element.

    (To get access to the Nightly builds you will need to purchase a license for Metro Elements, which is well worth it, so go buy a license!)

    After installing the Metro Elements, in your app you want to add a reference to Metro Elements:

    Now in the page attributes you need to include an alias for the MetroElements:

    Read more...