title: Return file for Saving from HttpPost Asp.Net MVC method
body: <p>I have an Asp.Net MVC project, and on one page of it, user can edit loaded data into table(change images, strings,items order, etc...). </p>
  
  <p>After all edits have made, the client pushes Download button, and save the resulted xml-file on his hard-drive for the next manipulations in future.</p>
  
  <p>So i have a simple html form:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code> &lt;form name="mainForm" data-ng-submit="sendForm()" ng-controller="ImportController" novalidate enctype="multipart/form-data"&gt;
  
      &lt;!-- table structure definition removed for briefing --&gt;
  
      &lt;td&gt;
          {{data.Items[$index].Id}}
      &lt;/td&gt;
      &lt;td&gt;
          &lt;img class="center-cropped" ng-src="data:image/jpg;base64, {{data.Items[$index].Image}}"&gt;
      &lt;/td&gt;
      &lt;td&gt;
          &lt;input class="form-control" type="text" value="{{data.Items[$index].LastName}}" /&gt;
      &lt;/td&gt;
  
      &lt;td&gt;
          &lt;input class="form-control" type="text" value="{{data.Items[$index].FirstName}}" /&gt;
      &lt;/td&gt;
      &lt;td&gt;
          &lt;input class="form-control" type="text" value="{{data.ClaimItems[$index].MiddleName}}" /&gt;
      &lt;/td&gt;
      &lt;input class="btn-success" id="submit-btn" type="submit" data-ng-disabled="mainForm.$invalid" value="Download" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>This form data is sent through angularJs function call which looks like:</p>
  
  <pre><code>$scope.sendForm = function () {
  
      // some preparations to send image data through json
      for (var i = 0; i &lt; $scope.data.Items.length; i++) {
          $scope.data.Items[i].ImageAsString = $scope.data.Items[i].Image;
      }
  
      $http.post("Download", { array: $scope.data })
          .success(function (responseData) {
              console.log(responseData);
          })
          .error(function (responseData) {
              console.log("Error !" + responseData);
          });
  };
  </code></pre>
  
  <p>After this function is called, the prepared http post request is sent to asp.net mvc <strong>Download</strong> action:</p>
  
  <pre><code>    [HttpPost]
      public FileResult Download(ItemsArrayWrapper array)
      {
         // here goes incoming data processing logic
         // ...
  
         return File(array.ConvertToItemsArray().Serialize(), "text/xml", name);
      }
  </code></pre>
  
  <p>I want my Download method to return FileResult, so, that a file saving dialog will appear on the client. But nothing is happening.</p>
  
  <p>I've tryed to construct various Response headers, to return different MimeTypes, change return types of Download method, and even tryed to call [HttpGet] method from Download method, but still nothing is appeared on the client. </p>
  
  <p>Searched in browser network monitoring - there is only one POST request is sent.</p>
  
  <p>Is it possible to send data from HttpPost method to client, that has been called from angularJs function in a such way? What i am missing, and why the saving dialog is not showed in browser?</p>
  
  <p>Or can anyone suggest any other more suitable solutions to achieve this?</p>