一个页面要传递FileModel 和InformationModel
首先自己先建一个Model
public class MyViewModels
{
public Models.File File { get; set; }
public Models.Information Information { get; set; }
}
然后在页面添加
@model WebApplication2.Models.MyViewModels
最后在action里面处理
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SavaInformation(MyViewModels o)
{
if(ModelState.IsValid)
{
db1.information.Add(o.Information); ;
db1.SaveChanges();
return RedirectToAction("Success");
}
return RedirectToAction("Fail");
}