Note that there are some explanatory texts on larger screens.

plurals
  1. POASP .NET MVC ViewModel object is not preserved
    primarykey
    data
    text
    <p>I am sort of new to MVC so pardon my ignorance. I am using IoC ( StructureMap ) and I have a need to pass in an instance of what I consider to be a set of Controls to each view, so I have created ViewModels in order to accomodate this. The view model is populated with an instance of the Controls and the View is then rendered. When a user performs a POST, the Controls are not being passed back to the Action.</p> <p><b>Snip from the Controller</b></p> <pre><code>Private _WebControls As Products.Services.IControlsRepository Private _customerRepo As Profiles.Services.ICustomerRepository Sub New() Me.New(ObjectFactory.GetInstance(Of Products.Services.IControlsRepository), ObjectFactory.GetInstance(Of Profiles.Services.ICustomerRepository)) End Sub Sub New(ByVal webRepo As Products.Services.IControlsRepository, ByVal custRepo As Profiles.Services.ICustomerRepository) _WebControls = webRepo _customerRepo = custRepo End Sub &lt;HttpGet()&gt; Function SendPassword() As ActionResult Dim vm As New SendPasswordViewModel vm.Controls = _WebControls Return View(vm) End Function &lt;HttpPost()&gt; Function SendPassword(ByVal model As SendPasswordViewModel) As ActionResult If ModelState.IsValid Then If _customerRepo.SendPassword(model.EmailAddress, model.Controls.WebControls.MacsDivision) = True Then model.SendPasswordResponseMessage = "Email successfully sent. Please check your email for your password." Else model.SendPasswordResponseMessage = "No account was found with the email that you provided." End If End If Return View("SendPassword", model) End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload