10. Januar 2012 02:10
It was quite a suprise to me to find out that Nancy uses host header binding by default. I created my Nancy host like this:
var Host = new NancyHost( new Uri( "http://localhost:8080 ), ServiceEndpointBootstrapper );
This works fine when calling the app using localhost, however if you use for instance 127.0.0.1 or the machine name you will see:
HTTP Error 400. The request hostname is invalid.
Host header binding means taking the host from the request headers. Here is a snippet of the browser request for the nancy host that does not work:
GET http://MyServer:8080/ HTTP/1.1
The host header is the one taken into account - it is matched against the one used to verify whether nancy should pick up the request. You see the use of host headers mostly when running multiple web sites on one ip and port, especially with web hosting companies that cannot use different ports for obvious reasons and cannot affort to have a dedicated IP for each site.
I do not know if there is a way to disable host header binding, however you can bind multiple endpoints using the NancyHost constructor. Perhaps the default is not that bad because it allows you for instance to just host an app locally which is a nice model for some applications.
12. Dezember 2011 14:43
I noticed that Response.AsJson causes errors with larger responses - first I was quite sure to have spotted a flaw, but this is intentional. There are two limits you can set for JSON objects, the total size and the recursion depth. You can set those via
Nancy.Json.JsonSettings.MaxJsonLength = <length in bytes>;
Nancy.Json.JsonSettings.MaxRecursions = <recursion depth>;
I guess the intention is similar to the limits on messages in WCF. Unfortunately there is no real reference documentation for Nancy at this point so it takes some time to dig such stuff out. I hope this will change in the future since this project is really well made and the team is great on supporting in their forums.
I'll add this to SoapWatch when I find time.
3. Dezember 2011 11:34
I added a small article about a little one day project that I used to fiddle around with Nancy and FiddlerCore.Check it out here.