Cómo enviar datos de vuelta al controlador en MVC usando knockout

Tengo el siguiente código:

Index.cshtml:

@using System.Web.Script.Serialization
@model MvcApplication3.Models.Person

<script src="../../Scripts/knockout-2.1.0.js" type="text/javascript"></script>

    <!-- This is a *view* - HTML markup that defines the appearance of your UI -->


<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>


<script type="text/javascript">

    var initialData = @Html.Raw(new JavaScriptSerializer().Serialize(Model));

    // This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
    function AppViewModel() {
        this.firstName = ko.observable(initialData.FirstName);
        this.lastName = ko.observable(initialData.LastName);

    }

    // Activates knockout.js
    ko.applyBindings(new AppViewModel());

</script>

Controlador de casa:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication3.Models;

namespace MvcApplication3.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var people = new PeopleEntities();

            var person = people.People.First();

            return View(person);
        }

        [HttpPost]
        public ActionResult Index(Person person)
        {
            //Save it

            return View();
        }
    }
}

Básicamente, lo que hace es cargar a una persona de la base de datos y el uso de nocauts crea campos editables para el nombre y el apellido. Carga los valores en los campos.

Esto funciona bien.

Sin embargo, no estoy seguro de cómo volver a publicar los cambios en el controlador para guardarlos. Tendrían que ser deserializados y volver a colocarlos en el modelo y luego publicarlos. No estoy seguro de cómo hacer esto.

¿Alguna ayuda?

Respuestas a la pregunta(1)

Su respuesta a la pregunta