asp.net mvc - ASP MVC4: A issue when manipulating variable value in controller -


thanks everyone's effort of helping me out, i'm facing problem in controller below, make simple , easy:

   controller c{         public list<model> a;        //used in action a, if it's searched list, don't initialize;        public bool searched = false;          public actionresult a(){           if(searched){              viewbag.a = a;           }else           //initial list           = db.model.where();           .....           return view()        }         //return result list when people search keywords        public actionresult b(string str){           = db.model.where(d=> d.id = str);           search = true;        }      } 

but, turned out value of both , researched never changed after b called

did miss critical knowledge in .net mvc?

any related articles welcomed

thanks

you should use tempdata keep value after redirect. tempdata designed for. in example be:

controller c{         public actionresult a(){           tempdata["str"] = "this a";           return redirecttoactionb()        }        public actionresult b(){           tempdata["str"] += "this b";           return view()        }      } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -