Does anyone know when model binding takes place in the request lifecycle? The reason I ask is that I'm running into some localization issues.
Does Model Binding happen before OnActionExecuting is executed?
Currently I set the current culture in a global action filters OnActionExecuting method but this isn't being respected when performing model binding. The request is a POST.
Thanks in advance.
Model binding allows controller actions to work directly with model types (passed in as method arguments), rather than HTTP requests. Mapping between incoming request data and application models is handled by model binders.
Using the Razor syntax instead of plain HTML it is very easy to construct and bind your form elements to the corresponding data. In this case the label will show the value of the Display attribute in the User class and the values of the user will be filled in the textboxes.
So the two-way data binding means we can perform both read and write operations.
I would suggest you to set the culture at a very earlier point not in action filter. In my current project I've set the culture in the Application_AcquireRequestState
event in Global.asax.cs. You can try that.
protected void Application_AcquireRequestState(Object sender, EventArgs e)
{
// set the culture
}
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