2
我在Asp.Net MVC的模型綁定中遇到了一個問題。我有一個像下面視圖模型,綁定排除不工作ASP.Net中的子對象的模型綁定MVC
public class ArticleViewModel : BaseViewModel
{
public Article art { get; set; }
public List<ArticleAttachment> attachments { get; set; }
}
我試圖排除模型作爲我的操作方法如下圖所示的「條」子對象上結合的性質,
[HttpPost]
[ValidateInput(false)]
public ActionResult New([Bind(Exclude = "art.Abstract")]ArticleViewModel articleVM)
{
但模型綁定填充即使使用上述設置,該屬性也稱爲摘要。
請讓我知道如果我做錯了什麼。在進行模型綁定時,我需要排除Article子對象中的一些屬性。
看到這個: - http://stackoverflow.com/questions/5341917/asp-net-mvc-3-model-binding-and-form-fields – 2011-12-21 10:00:04
謝謝!我嘗試設置前綴,但沒有運氣 – Bala 2011-12-21 10:07:17
嘗試[綁定(排除=「摘要」) – RickAndMSFT 2011-12-21 21:02:08