Bind Exclude not working Model Binding for child objects in ASP.Net MVC

坚强是说给别人听的谎言 提交于 2019-12-11 02:44:30

问题


I got into a issue in Model Binding in Asp.Net MVC. I have view model like below,

public class ArticleViewModel : BaseViewModel
    {        
        public Article art { get; set; }
        public List<ArticleAttachment> attachments { get; set; }
    }

I am trying to exclude model binding a property on the "Article" child object as seen below in my action method,

[HttpPost]
[ValidateInput(false)]
public ActionResult New([Bind(Exclude = "art.Abstract")]ArticleViewModel articleVM)
 {

But the model binder populates the property called Abstract even with the above setting.

Please let me know if i am doing anything wrong. I need to exclude some of the properties in the Article child object when doing Model binding.

来源:https://stackoverflow.com/questions/8587893/bind-exclude-not-working-model-binding-for-child-objects-in-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!