後清空我是新來的ASP和一般的編程,所以我可能做一些根本性的錯誤,但這裏有雲: 每次我返回查看我的控制器,我用在該模型控制器被清空。例如:型號返回視圖
Account acc;
public ActionResult Index()
{
acc = new Account(accountName, password);
return View(acc)
} //At this point there still is a acc object
public ActionResult Edit(string name, string pass)
{
//Here the acc object is null
acc.userName = name;
acc.password = pass;
}
我的問題是如何存取權限當前正在使用的帳戶或方法來保存用去查看()
編輯1
當我試圖發送模式使用TempDate我還是encounterd同樣的問題:
Account acc;
public ActionResult Index()
{
acc = new Account(accountName, password);
TempDate["account"] = acc;
return View(TempDate["account"])
} //TempDate contains 1 object
public ActionResult Edit(string name, string pass)
{
//TempData is empty here
TempDate["account"].userName = name;
TempDate["account"].password = pass;
Return View("Index", TempDate["account"]);
}
的可能的複製[什麼是存儲在asp.mvc請求之間數據的正確方法(http://stackoverflow.com/questions/15336991/what-is-correct-way-of-storing-data-between-請求式-ASP-MVC) –