Answer the question
In order to leave comments, you need to log in
How to update the data returned by the view to the controller?
there is a construct like
Options _options;
HomeController(IOptions options)
{_options = options;}
void ActionResult Index(Options options)
{_options = options
Redirect...}
... Each time the homepage is navigated, the controller's constructor restarts and overwrites _options, preventing them from most make the changes created in the view and controller. How can this be bypassed?
Answer the question
In order to leave comments, you need to log in
You need to study the ASP MVC lifecycle to understand that a controller instance lives exactly from request to response. With each new request, a new instance of the controller is created, which means that
void ActionResult Index(Options options)
{_options = options }
ActionResult Index(Options options)
, then create a global static class to store some parameters for all requests. If these settings are individual for each user, then you can store them in sessions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question