I tried adding this in the bootstrapper in the ApplicationStartup override.
pipelines.AfterRequest.AddItemToStartOfPipeline(ctx =>
{
ctx.Request.Headers["x-fcr-version"] = "1";
});
Its giving me errors.
Can anyone point me in the right direction?
Notice how you are trying to set the Request
while trying to manipulate the Response
?
Try this..
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
{
base.RequestStartup(container, pipelines, context);
pipelines.AfterRequest.AddItemToEndOfPipeline(c =>
{
c.Response.Headers["x-fcr-version"] = "1";
});
}
This is what my Response
looks like..
Or .. you can use Connection Negotiation if you're going to set it at the module level...
Get["/"] = parameters => {
return Negotiate
.WithModel(new RatPack {FirstName = "Nancy "})
.WithMediaRangeModel("text/html", new RatPack {FirstName = "Nancy fancy pants"})
.WithView("negotiatedview")
.WithHeader("X-Custom", "SomeValue");
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With