一、mvc控制器接收数据的两种方法
A方法:
public ActionResult ProcessAdd()
{
string username=Request[“UserName”];
int Age=Request[“Age”];
}
B方法:FormCollection参数,在表单提交时会自动把前端的值封装在里面传至后台
public ActionResult ProcessAdd(FormCollection collection)
{
string username=Request[“UserName”];
int Age=int.Parse(collection[“Age”]??“0”);//collection中获取到的是object类型,需要转换
}