MVC 4 Post data is resetting unchanged properties?

Vtortola's suggestion is very valid that you should not be exposing your entities directly to the view. I will only explain why values of entity are being reset even after using ExcludeAttribute . Indeed they are not being reset.

Model binder creates a new object which is populated with default values and then values from request are written to the object. Using ExcludeAttribute here will have no effect because what it does is that it simply ignores the values for excluded from request parameters. But still its a new object nevertheless (not the object from db).

So if you want non editable values to be present in the model bound object you need to provide these values in the request object (hidden fields are one option).

You can exclude properties from the binding with the ExcludeAttribute.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions