3

I'm building a restful API with NancyFx. Now, I wanted my routes to send back a Reponse with a StatusCode and a ReasonPhrase of my choice depending on what I get from the clients. Here's some code:

Post["/PostSomething"] = _ =>
            {
                .
                .
                .

                return Negotiate
                    .WithModel(myDTO)
                    .WithStatusCode(HttpStatusCode.XX)
                    .WithReasonPhrase("My reason");
            };

The problem I find is that whenever I set an "ReasonPhrase", is ignored if I previously set a StatusCode. In other words, I can only set a StatusCode of my choice without a customized ReasonPhrase, or I can set a ReasonPhrase and send back the "HttpStatusCode.Ok" since I cannot control it anymore.

I found a similar question in this link: How to get a response from the Nancy Negotiator?. But looks never it never got the answer.

If I missed some info, ask me please.

Any thoughts?

Community
  • 1
  • 1
monkeyBug
  • 555
  • 1
  • 4
  • 16
  • What host are you using? It shouldn't be a problem to set both. I think it could be the order the status code/reason phrase is set on the underlying context/response in one of the hosts. I haven't seen this with the OWIN host at least. – khellang Mar 24 '15 at 14:17

0 Answers0