c# - ASP .Net MVC get value from layout -


i'm pretty new mvc although familiar webforms, quite shift , i'm still learning, there 1 problem have come across having difficulty finding answer for.

suppose in layout have dropdown box selecting country. have view displays product details such stock, item price, distributor etc... of dependent on country have selected. there other views display information dependent on country keep dropdown in layout , have selected value persist.

is best way persist selected country , use value in controllers through storing in session, or there better approach may missing?

the approach web-forms quite bit different. however, model view controller designed mimic stateless nature of hypertext transfer protocol. creates incredible amount of flexibility, each view embody exact state create.

you have several options:

  • hidden
  • session
  • viewbag
  • temporary data

the approach take vary based on context, sadly missing. each have severe draw back, 1 hindrance life cycle. wary of session, can become orphaned bogging application down.

once have more context, better answer ensue. persist through entire application, or persist through 1 page several page states?


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -