嘗試重新發布視圖,但即時獲得我想要的字段爲空。在MVC中的Http發佈後渲染相同的視圖
繼承人的控制器......
public ActionResult Upload()
{
VMTest vm = new VMTest();
return View(vm);
}
[HttpPost]
public ActionResult Upload(VMTest vm, String submitButton)
{
if (submitButton == "Upload")
{
//do some processing and render the same view
vm.FileName = "2222"; // dynamic creation of filename
vm.File.SaveAs(@vm.FileName); // save file to server
return View(vm);
}
else if (submitButton == "Save")
{
//read the file from the server
FileHelperEngine engine = new FileHelperEngine(typeof(PaymentUploadFile));
PaymentUploadFile[] payments = (PaymentUploadFile[])engine.ReadFile(@vm.FileName); // the problem lays here @vm.FileName has no value during upload
//save the record of the file to db
return View("Success");
}
else
{
return View("Error");
}
}
我已經有一個@ Html.HiddenFor(型號=> Model.FileName)我的觀點裏。
但是我仍然得到了Model.FileName的空值。
任何幫助,請
感謝
非常感謝。我一直花費幾天來解決這個問題..只有ModelState.Remove是關鍵......謝謝@Darin – roggss 2012-02-10 09:18:51