In C# MVC you can use model binding to automatically parse variables to a model.
public class RegistrationForm {
string Name {get;set;}
string Address {get;set;}
}
public ActionResult Register(RegistrationForm register) {
...
}
If I pass the Name and Address variables they are directly available in the register object.
Is it possible to call this binding manually if you have the variables in a string? EG:
var s = "name=hugo&address=test";
//dosomething to get RegistrationForm register
//register.Name == hugo
I know I can get a NameValueCollection with HttpUtility.ParseQueryString(s); and then use reflection to get the properties of RegistrationForm and check if the values exists, but I was hoping I could use the actually binding method MVC uses.