We are having an issue with Nancy’s default model binder. Given the below…
public class Foo
{
public Foo()
{
}
public string Name { get; set; }
public Bar Bar { get; set; }
}
public class Bar
{
public string Name { get; set; }
}
with elements like…
<input type="text" value="Name" />
<input type="text" value="Bar.Name" />
With the default model binder used like so..
var foo = this.Bind<Foo>();
This correctly binds Foo.Name but fails to bind Foo.Bar.Name
Is there a way to enable this kind of binding with the default binder or do we need to roll our own? If so are there any good examples?
Why not try this. I’m fairly sure the recursion could be optimised, and that something will come up where it doesn’t work, and that it could be put somewhere cleverer than a IModelBinder, but it basically does what you want.