title: Send Json object and file to controller with Javascript in MVC
body: <p>I have a Json object like :</p>
  
  <pre><code>  var appversion = { "Id": "", "Version": "", "HelpSystemId": "", "Content": "", "FileName": "", "IsLatest": "", "LastModify": "", "AppVersionChangsets": [] };
          appversion.Id = $("#Id").val();
          appversion.Version = $("#Version").val();
          appversion.HelpSystemId = $("#HelpSystemId").val();
          appversion.IsLatest = $("#IsLatest").val();
          appversion.LastModify = $("#LastModify").val();
  </code></pre>
  
  <p>and a file that I get it this way in my form :</p>
  
  <pre><code>&lt;div class="form-group"&gt;
          @Html.MyLabelFor(model =&gt; model.Content, new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              &lt;input type="file" id="_file" name="_file" /&gt;
              &lt;button onclick="abortRead();"&gt;Cancel read&lt;/button&gt;
              &lt;div id="progress_bar"&gt;&lt;div class="percent"&gt;0%&lt;/div&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>and I send it to my controller : </p>
  
  <pre><code> $.ajax({
            url: '/AppVersion/Create2',
            data: JSON.stringify(appversion),
            type: 'POST',
            contentType: 'application/json;',
            dataType: 'json',
           success: function (result) {
                 if (result.Success == "1") {
                      window.location.href = "/AppVersion/index";
                 }
                 else {
                     alert(result.ex);
                 }
             }});
  </code></pre>
  
  <p>controller is : </p>
  
  <pre><code>    [HttpPost]
      [AcceptVerbs(HttpVerbs.Post)]
      public JsonResult Create2(AppVersion appversion)
      {
      //Some Code
      }
  </code></pre>
  
  <p>my problem is I can not access to my file in controller . I just get my json object .how can I send file with Json Object to Controller ? </p>
  
  <pre><code>  if (Request.Files["file"].ContentLength &gt; 0)
                  {
                      Stream str = Request.Files["file"].InputStream;
                      byte[] data = new byte[str.Length];
                      str.Read(data, 0, System.Convert.ToInt32(str.Length));
                  }
  </code></pre>