none
MVC Controller explanation needed RRS feed

  • Question

  • Whenever i load a controller from its respective view, a new object of the controller is created.

     

    Now the issue is suppose i want to persist a value for the controller as long as i am in the current view but because on every constructor call a new object is created and constructor is called i am not able to achieve this. In my opinion a new object of constructor should only be changed when the view is changed and on the current view the current controller object should be used.

    Wednesday, February 26, 2020 11:56 AM

All replies

  • can you be more specific?
    How are the View and ViewModel linked?
    are you using an IOC container?

    Wednesday, February 26, 2020 4:52 PM
  • Hi YSC_CHEEMA,

    How is the question going? Please let me know if you need further assistance.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 3, 2020 2:31 AM
  • Hi YSC_CHEEMA,

    Since your issue is more related to ASP.NET, so it will be more appropriate to ask your question in ASP.NET Forums

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 12, 2020 5:48 AM