Get url parameters in NancyFx

There are 2 things that you are trying to get from the URL. One is a part of the path hourly – and the other is the parameters in the query string – namely the values for from and to.

You can get to the part of the path through the parameter to the handler – the x in your example.

You can get to the query string through the Request which is accessible on the NancyModule.

To put this in code:

Get["consumptions/{granularity}"] = x =>
{
    var granularity = x.granularity;
    var from = this.Request.Query["from"];
    var to = this.Request.Query["to"];
}

The variables granularity. from, and to are all dynamic, and you may need to convert them to whatever type you want.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)