Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8560919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:23:11+00:00 2026-06-11T16:23:11+00:00

I inherited a WCF project containing some badly constructed routes (which work) that I

  • 0

I inherited a WCF project containing some badly constructed routes (which work) that I need to migrate into a new NancyFx project. I need to be able to define routes in my Nancy app that respond to the same GET requests. I cannot change the routes for the time being.

In the WCF project, a GET request to …

http://localhost:12345/webapi/GetUsers?UserId=567&Language=en

matches this UriTemplate:

UriTemplate = "GetUsers?UserId={userId}&Language={language}

I was hoping this would be the equivalent in Nancy

Get["/GetUsers?UserId={userId}&Language={language}"] = p => { ... }

but the same GET request results in a 404.

Is there a way to structure my Nancy route to respond to this GET request? If not, any work-arounds?

I know this is horrible but its temporary until I can schedule time with our UI team to rewrite the front-end to call proper rest-full URLs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:23:12+00:00Added an answer on June 11, 2026 at 4:23 pm

    John,

    Your route would be /GetUsers (how are you handling the /webapi part by the way? Is that the base url of your application or are you setting up a module path?) and you would read the query-string using the Request.Query member.

    The Query property returns a DynamicDictionary which enables you to access the values as either properties Request.Query.UserId or as a dictionary Request.Query["UserId"]

    You cannot make the query-string part of pattern that needs to be matched in order for the routes to be invoked. What you can do, if you really want to, is to use the route condition, which is the second parameter on the route declaration. This gives you control over a predicate which determines if the route is OK to be used or not. So you could do something like this

    Get["/GetUsers", ctx => ctx.Request.Query.UserId.HasValue && ctx.Request.Query.Language.HasValue] = p {... }
    

    You could then refactor it all to an extension method, on NancyContext, that makes it a bit tidier

    Get["/GetUsers", ctx => ctx.HasQueryValues("UserId", "Language")] = p {... }
    

    and make the extension something like

    public static bool HasQueryValues(this NancyContext context, params string[] values)
    {
       return values.All(x => context.Request.Query[x].HasValue);
    }
    

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited some Silverlight\WCF code and now need to implement some new features.
I have inherited some code that queries a DB over a WCF service and
I recently inherited a Silverlight web project that uses WCF services to handle asynchronous
I inherited several projects Javas in my new job, but I'm having some problems
I inherited a system that stores default values for some fields in some tables
I have inherited a WCF service which acts as a file cache (each file
I have set up some WCF services that I use to call from javascript
I'm working on a bigger project which uses WCF data service and OData to
I'm write a simple wcf service that submit request to some gateway to be
In my WCF service I have implemented a custom encoder which inherits from System.ServiceModel.Channels.MessageEncoder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.