My registration view doesnt post the input

I'm trying to do a login and register view with c#, html and MVC. First of all, I have a table in my database called "Usuarios" with columns like: Username, Contrasena (Password), Email, etc). When i fill all the text boxes to test if my controller update my database (adding the new user) it doesnt work.

My RegisterClient() method in ClientController:

[HttpPost]
        [AllowAnonymous]
        public ActionResult RegisterClient(RegisterViewModel model)
        {
        if(ModelState.IsValid)
        {
            Cliente Client = new Cliente(model.NombreUsuario, model.Password, model.Nombre, model.Apellido, model.Domicilio, model.TipoDoc, model.NumeroDoc, model.Telefono);

            using (var db = new ContextoDB())
            {

                if (db.Usuarios.Any(u => u.NombreUsuario == Client.NombreUsuario))
                {
                    ViewBag.DuplicateMessage = "Nombre de usuario en uso.";
                    return View("RegisterClient", model);
                }

                db.Usuarios.Add(Client);
                db.SaveChanges();
            }
            ModelState.Clear();
            ViewBag.SuccessMessage = "Registado excitosamente!";

            return RedirectToAction("RegistrationSuccess", "Account");
        } else
        {
            return View(model);
        }


    }

The RegisterClient View:

<div class=“register-box”>
<h4 class=“h4-header”>Registro paso 2 de 2 </h4>

        @Html.ValidationSummary(true, "Register failed. Check your login details.")
        &lt;fieldset class="fieldset-box client-field"&gt;

            &lt;div class="user-info-box"&gt;
                &lt;h3&gt; Datos de la cuenta&lt;/h3&gt;
                &lt;div class="editor-field"&gt;
                    @Html.TextBoxFor(model =&gt; model.NombreUsuario, new { Class = "YourBackgroundClass", Placeholder = "Usuario" })
                    @Html.ValidationMessageFor(model =&gt; model.NombreUsuario, "", new { @class = "text-danger" })
                &lt;/div&gt;

                &lt;div class="editor-field"&gt;
                    @Html.TextBoxFor(model =&gt; model.Email, new { Class = "YourBackgroundClass", Placeholder = "Email" })
                    @Html.ValidationMessageFor(model =&gt; model.Email, "", new { @class = "text-danger" })
                &lt;/div&gt;

                &lt;div class="editor-field"&gt;
                    @Html.PasswordFor(model =&gt; model.Password, new { Class = "YourBackgroundClass", Placeholder = "Contraseña" })
                    @Html.ValidationMessageFor(model =&gt; model.Password, "", new { @class = "text-danger" })
                &lt;/div&gt;

                &lt;div class="editor-field"&gt;
                    @Html.PasswordFor(model =&gt; model.ConfirmPassword, new { @class = "YourBackgroundClass", Placeholder = "Confirmar contraseña" })
                    @Html.ValidationMessageFor(model =&gt; model.ConfirmPassword, "", new { @class = "text-danger" })
                &lt;/div&gt;

            &lt;/div&gt;

            &lt;div class="personal-info-box"&gt;
                &lt;h3&gt; Datos personales&lt;/h3&gt;
                &lt;div class="editor-field"&gt;
                    @Html.TextBoxFor(model =&gt; model.Nombre, new { Class = "YourBackgroundClass", Placeholder = "Nombre" })
                &lt;/div&gt;

                &lt;div class="editor-field"&gt;
                    @Html.TextBoxFor(model =&gt; model.Apellido, new { Class = "YourBackgroundClass", Placeholder = "Apellido" })
                &lt;/div&gt;
                &lt;div class="editor-field"&gt;
                    @Html.TextBoxFor(model =&gt; model.Domicilio, new { Class = "YourBackgroundClass", Placeholder = "Domicilio" })
                &lt;/div&gt;
                &lt;div class="editor-field"&gt;
                    @Html.TextBoxFor(model =&gt; model.Telefono, new { Class = "YourBackgroundClass", Placeholder = "Telefono" })
                &lt;/div&gt;

                &lt;div class="editor-field"&gt;
                    @Html.TextBoxFor(model =&gt; model.NumeroDoc, new { Class = "YourBackgroundClass", Placeholder = "Numero de documento" })
                &lt;/div&gt;
            &lt;/div&gt;

        &lt;/fieldset&gt;

        &lt;form action="" method="post"&gt;
            &lt;input type="submit" class="but-next next round" name="upvote" value="&amp;#8250;" /&gt;
        &lt;/form&gt;

        &lt;a href="#" class="but-next next round"&gt;&amp;#8250;&lt;/a&gt;
    &lt;/div&gt;

When i fill all the boxes, it triggers the validation messages.

#c-sharp #html

4 Likes1.55 GEEK