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 7982321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:38:51+00:00 2026-06-04T10:38:51+00:00

The documentation suggests the NancyFx helps me out WRT deserialization of json request body,

  • 0

The documentation suggests the NancyFx helps me out WRT deserialization of json request body, but I’m not sure how. See test below to demonstrate:

[TestFixture]
public class ScratchNancy
{
    [Test]
    public void RootTest()
    {
        var result = new Browser(new DefaultNancyBootstrapper()).Post(
            "/",
            with =>
                {
                    with.HttpRequest();
                    with.JsonBody(JsonConvert.SerializeObject(new DTO {Name = "Dto", Value = 9}));
                });

        Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
    }

    public class RootModule : NancyModule
    {
        public RootModule()
        {
            Post["/"] = Root;
        }

        private Response Root(dynamic o)
        {
            DTO dto = null;//how do I get the dto from the body of the request without reading the stream and deserializing myself?

            return HttpStatusCode.OK;
        }
    }

    public class DTO
    {
        public string Name { get; set; }
        public int Value { get; set; }
    }
}
  • 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-04T10:38:53+00:00Added an answer on June 4, 2026 at 10:38 am

    Model-binding

    var f = this.Bind<Foo>();
    

    EDIT (to put above into context for the benefit of other readers of this question)

    public class RootModule : NancyModule
    {
        public RootModule()
        {
            Post["/"] = Root;
        }
    
        private Response Root(dynamic o)
        {
            DTO dto = this.Bind<DTO>(); //Bind is an extension method defined in Nancy.ModelBinding
    
            return HttpStatusCode.OK;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying svn add *.py --force As the documentation suggests , but I know
The jQuery documentation suggests storing additional info per DOMElement using data() . But I'm
The YUI Test -Code Coverage Utility documentation suggests that we need some jar files
The subject says it all, really. Documentation, insofar as it exists at all, suggests
Wordpress' documentation suggests adding the following to functions.php to enable what I want to
Boost.Asio documentation suggests the following exception handling pattern : boost::asio::io_service io_service; ... for (;;)
All the documentation suggests that ctrl+comma should bring up the navigate to dialog. When
The Django Celery documentation suggests there are URLs I can check to get the
Using a default/vertical form, the bootstrap documentation suggests that the submit button sits underneath
Update: mogenerator works, with a template modification The Core Data documentation suggests using the

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.