C# mvc中怎么从前台向后台发送model

如题所述

第一种:直接Return View(model); 前台用@Model就能获取到
第二种:直接使用ViewData[""]来传值
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-10-14
前台还是老样子做个form提交或者用js post,没什么变化
后台control接受的时候用model类去接就行了,服务器会自动按照类中的属性去赋值的

model:
public class Model
{
public string ProduceName { get; set; }
}

前台:
<form id="..." action="/XXX/ProduceM" method="post">
<label>生产名称:</label>
<input id="ProduceName" name="ProduceName"/>
</form>

后台:
[HttpPost]
public ActionResult ProduceM(Model ProduceModel){...}本回答被提问者和网友采纳