views:

36

answers:

2

I have a property in a dto that I don't want the modelbinder/view to use the get on? Is there an attribute I can decorate it with to stop them from interrogating it?

Thanks

A: 

See the "Include" and "Exclude" properties on the BindAttribute:

http://msdn.microsoft.com/en-us/library/system.web.mvc.bindattribute_members.aspx

Patrick Steele
+2  A: 
public class Model
{
  [Bindable(false)] // this is the attribute you can use...
  public int ModelId { get; set; }
}
Jab