title: Form not submitting and no error is being produced with MVC
body: <p>I have a form in my MVC application that in theory should submit data back to my database using a Repository class.</p>
  
  <p>However, when I submit the form (<strong><a href="http://localhost:1028/Admin/NewUser/" rel="nofollow noreferrer">http://localhost:1028/Admin/NewUser/</a></strong>), the URL changes to where the form should be submitting to, which is fine (<strong><a href="http://localhost:1028/Admin/NewUser/Submit" rel="nofollow noreferrer">http://localhost:1028/Admin/NewUser/Submit</a></strong>), but once it has been submitted, it should send the user to a confirmation page.</p>
  
  <p>From what I can tell, I'm moving through all my pages correctly until it comes to the submit, where it displays the form again but under <strong>/Admin/NewUser/Submit</strong> and the data is not inserted into the database.</p>
  
  <p>This is the ActionResult I'm using:</p>
  
  <pre><code>Public Function Submit() As ActionResult
           Try
              Dim user = New hdUser() With { _
                  .userLogon = Request.Form("UserLogin"), _
                  .userPass = Request.Form("UserPassword"), _
                  .userEmail = Request.Form("UserEmail"), _
                  .RealName = Request.Form("UserFullName"), _
                  .isLive = 1, _
                  .avatar = "noavatar.gif" _
               }
              userRepository.Add(user)
              userRepository.Save()
  
              Return Redirect("/Admin/NewUser/Confirm")
          Catch ex As Exception
              ModelState.AddModelError("Error", ex)
          End Try
          Return View()
      End Function
  </code></pre>
  
  <p>I'm fairly new to MVC so I'm not entirely sure if the above is correct or not.</p>
  
  <p>And in my data repository class <strong>UserRepository.vb</strong>, the two functions I'm using are:</p>
  
  <pre><code>Public Sub Add(ByVal user As hdUser) Implements IUserRepository.Add
              db.hdUsers.InsertOnSubmit(user)
          End Sub
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Public Sub Save() Implements IUserRepository.Save
              db.SubmitChanges()
          End Sub
  </code></pre>
  
  <p>And the form I have created is:</p>
  
  <pre><code>&lt;form action="/Admin/NewUser/Submit" method="post"&gt;
                  &lt;table border="0" cellpadding="0" cellspacing="2"&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;strong&gt;User's Full Name&lt;/strong&gt; &lt;br /&gt;
                           &lt;%=Html.TextBox("UserFullName")%&gt;
                              &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;strong&gt;User Login&lt;/strong&gt; &lt;br /&gt;
                           &lt;%=Html.TextBox("UserLogin")%&gt;
                              &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;strong&gt;Password&lt;/strong&gt; &lt;br /&gt;
                           &lt;%=Html.Password("UserPassword")%&gt;
                             &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;strong&gt;Email Address&lt;/strong&gt; &lt;br /&gt;
                           &lt;%=Html.TextBox("UserEmail")%&gt;
                           &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td align="right"&gt;&lt;input type="submit" value="Create" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>The code doesn't produce any errors but also doesn't seem to be submitting to the database. So I'm not entirely sure where I've gone wrong.</p>
  
  <p>It could be obvious to someone more experienced, but I really haven't a clue on this one.</p>
  
  <p>Is this my code that's causing the issue or some other fault?</p>
  
  <p>Thanks in advance for any help.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> Based on Zhaph - Ben Duguid comment, I have made the following edits:</p>
  
  <p><strong>AdminController.vb</strong></p>
  
  <pre><code>&lt;AcceptVerbs(HttpVerbs.Post)&gt; _
      Public Function NewUser(ByVal formValues As FormCollection) As ActionResult
          Try
              Dim user = New hdUser()
              user.userLogon = Request.Form("UserLogin")
              user.userPass = Request.Form("UserPassword")
              user.userEmail = Request.Form("UserEmail")
              user.RealName = Request.Form("UserFullName")
              user.isLive = 1
              user.avatar = "noavatar.gif"
              UpdateModel(user)
              userRepository.Add(user)
              userRepository.Save()
          Catch ex As Exception
              ModelState.AddModelError("Error", ex)
          End Try
          Return View()
      End Function
  </code></pre>
  
  <p><strong>NewUser.aspx</strong></p>
  
  <pre><code>&lt;%Html.BeginForm()%&gt;
              &lt;%=Html.ValidationMessage("Error")%&gt;
                    &lt;table border="0" cellpadding="0" cellspacing="2"&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;strong&gt;User's Full Name&lt;/strong&gt; &lt;br /&gt;
                           &lt;%=Html.TextBox("UserFullName")%&gt;
                              &lt;%=Html.ValidationMessage("Name", "*")%&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;strong&gt;User Login&lt;/strong&gt; &lt;br /&gt;
                           &lt;%=Html.TextBox("UserLogin")%&gt;
                              &lt;%=Html.ValidationMessage("Username", "*")%&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;strong&gt;Password&lt;/strong&gt; &lt;br /&gt;
                           &lt;%=Html.Password("UserPassword")%&gt;
                              &lt;%=Html.ValidationMessage("Password", "*")%&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;strong&gt;Email Address&lt;/strong&gt; &lt;br /&gt;
                           &lt;%=Html.TextBox("UserEmail")%&gt;
                           &lt;%=Html.ValidationMessage("Email", "*")%&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td align="right"&gt;&lt;input type="submit" value="Create" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
                  &lt;% Html.EndForm() %&gt;
  </code></pre>
  
  <p>Which now produces an error of <strong>The value '' is invalid.</strong> for me.</p>
  
  <p>Does this mean that form values aren't being passed correctly to the controller?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> I've made those edits in response Zhaph - Ben Duguid's edit and I've changed the Form elements to the DB field names (for testing at least). And now, when the page is submitted Name, Login and Email are all filled, password is blank (which I'm assuming is expected behaviour as per password boxes) but I still receive the <strong>"The value '' is invalid"</strong> error.</p>