Search code examples
nancy

Only Legacy routing is available after fresh install of NuGet package


For some reason after installing Nancy I only have access to what is referred to in the documentation as the legacy way to do routing :

Get["/"] = _ => "Hello World!";

The new syntax :

Get("/products/{id}", _ =>
    {
        //do something
    });

Results in the compiler error :

Non-invocable member 'NancyModule.Get' cannot be used like a method.

I installed the NuGet package for Nancy 1.4.3 in a class library project.


Solution

  • The new syntax is in the 2.0 pre-release versions so you either need to check the "pre-release" checkbox in the Nuget UI, or use -pre if you are using the commandline.

    Edit: the docs are a bit screwy there, not sure why they've been updated like that, but the "legacy routing" section is what you need if you want to use a non-prerelease version.