-1
這裏是視圖模型關於asp.net的MVC模型綁定和它的參數
public class ArticleViewModel
{
public string ID { get; set; }
public string Title{ get; set; }
public string Body { get; set; }
public List<BETag> TagsList { get; set; }
}
public class BETag
{
public string ID { get; set; }
public string Name { get; set; }
}
的行動
[HttpPost, AuthorizeEx]
public ActionResult AddArticle(ArticleViewModel articleViewModel)
{
//articleViewModel.Tags.Count == 0
//Request.Form["TagsList"] == "tag1, tag2..."
}
和AddArticle.cshtml
@Html.TextAreaFor(m => m.TagsList)
一部分我的問題是,爲什麼articleViewModel.Tags.Count
等於0
,但是 Request.Form["TagsList"]
等於"tag1, tag2..."
?如何正確綁定ArticleViewModel
?