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

  • Home
  • SEARCH
  • 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 7915401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:26:29+00:00 2026-06-03T14:26:29+00:00

Nancy passes my query-string and form values to my handlers via a dynamic variable.

  • 0

Nancy passes my query-string and form values to my handlers via a dynamic variable. The example below shows form values being passed in to a POST handler via the Nancy request e.g. Request.Form.xxx.

Handler

Post["/"] = _ =>
    {
        var userId = (string) Request.Form.userid;
        if (userId.IsEmpty()) return HttpStatusCode.UnprocessableEntity;
        return HttpStatusCode.OK;
    };

You can see that I am casting the userid to a string and then using a string extension method to check if the value is null or empty string (equivalent to string.IsNullOrEmpty()).

What I would prefer is to to have the extension method on the dynamic type so I could perform my sanity checks before doing anything else. I want code like this:

if(Request.Form.userid.IsEmpty()) return HttpStatusCode.UnprocessableEntity;

However, you cannot have extension methods for dynamic types. Also, you cannot check for the presence of a property via reflection. Welcome to the DLR.

Question

What is the easiest, safest way to perform pre-checks to ensure that the expected query/form values have been passed to my Nancy handler?

Thanks

  • 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-03T14:26:31+00:00Added an answer on June 3, 2026 at 2:26 pm
    Request.Form.userid.HasValue
    

    Works for all DynamicDictionary members, such as Form, Query and route parameters

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

Sidebar

Related Questions

I have a simple Nancy module. I want to pass in query string (q-s)
Here is a unit test that shows me authenticating my Nancy browser (other code
I am looking for help in writing a query of retrieving the values from
For example, from a following file: Name,Surname,E-mail John,Smith,john.smith@hotmail.com Nancy,Smith,nancy.smith@gmail.com Jane,Doe,jane.doe@aol.com John,Doe,john.doe@yahoo.com how do I
I have a long running process that is called via a Nancy Module Get
I have a Nancy JSON REST service that uses the following serialisation code... FormatterExtensions.AsJson(this.Response,
I want my Nancy site to accept Google/Facebook/OpenID authentication. Are there any existing solutions
I'm knocking together a demo app based upon Nancy.Demo.Authentication.Forms . I'm implementing Claims and
There is a variable $list , which has some array. printr_r($list); Gives something like:
For our sharepoint 2010 app's we need form base authentication(Claim base authentication). Is anybody

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.