title: How to update a view within a regular controller method (called from client)?
body: <p>How can I update a view from within a standard method defined within a controller?  The method is being called from a jquery plugin that I hookup.</p>
  
  <p>View:</p>
  
  <pre><code>    @model ViewModel
  
      @Html.EditorFor(model =&gt; model.First)
      @Html.EditorFor(model =&gt; model.Last)
  
      @Html.EditorFor(model =&gt; model.Junk)
  </code></pre>
  
  <p>Controller Method:</p>
  
  <pre><code>    // Called from third party jquery plugin
      public string DoSomeWorkAndUpdateMyView(string Id)
      {
          // Get persisted View from dbcontext...
          // Create a new Junk object with the new id and add it to the db context
          // Update the view with the newly added junk object
          ViewModel model = dbContext.GetViewStuff();
          model.Junk.Add(new junk);
  
          return View("JunkView", model);
      }
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>   ...
     onComplete: function (event, queueID, fileObj, response, data) 
                  {
                      $.ajax(
                  { url: '@Url.Action("ProcessForm","Home")',
                      data: { first: $("#fname").val() },
                      success: function (data) {
                          $("#fname").val(data);
                      }
                  })
                  }
     ...
  </code></pre>