感谢大家帮助我的努力,基本上我在下面的控制器中遇到了一个问题,让它简单易行:
Controller C{
public list<model> a;
//used in action A, if it's a searched list, then don't initialize;
public bool searched = false;
public ActionResult A(){
if(searched){
ViewBag.a = a;
}else
//initial the list
a = db.model.where();
.....
return view()
}
//return a result list when people search by keywords
public ActionResult B(string str){
a = db.model.where(d=> d.id = str);
search = true;
}
}
但是,事实证明,在 B 调用之后,a 和 researched 的值都没有改变
我是否错过了 .NET MVC 中的一些关键知识?
任何相关文章都非常欢迎
谢谢