asp.net mvc - .NET MVC: A Q when changing the 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're thinking state preserved between 2 web requests. when web request ends, entire controller destroyed , set information lost unless stored in persistent data store session or database.

if understand code correctly, if refactor code slightly, can achieve searching functionality under 1 action, , wouldn't need store data persistently.


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 -