title: why Request.files arrayList is empty? C#
body: <p>I am currently working on a website in which i have to implement a bug reporting module. In this module user will provide the screen-shot of the bug being reported with some other details. I am passing this data to controller using AJAX, jQuery. But in controller the Request.Files arrayList is shown empty and gives exception.
  I tried everything to resolve it but can't figured it out kindly help if anyone know. 
  Here is the HTML page</p>
  
  <pre><code>&lt;div class="row mt"&gt;
          &lt;div class="col-lg-12"&gt;
              &lt;div class="form-panel"&gt;
                  &lt;h4 class="mb"&gt;&lt;i class="fa fa-angle-right"&gt;&lt;/i&gt; Please provide Details about bug you have found&lt;/h4&gt;
                  &lt;form class="form-horizontal style-form" method="post" enctype="multipart/form-data"&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label class="col-sm-2 col-sm-2 control-label"&gt;Brief Description&lt;/label&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;input type="text" class="form-control round-form" placeholder="Provide brief description about bug here" id="bug_des"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label class="col-sm-2 col-sm-2 control-label"&gt;URL&lt;/label&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;input type="url" placeholder="Please provide ulr of the page where you found this bug" id="bug_url" class="form-control round-form"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label class="col-sm-2 col-sm-2 control-label"&gt;Screen-Shot&lt;/label&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;input class="form-control round-form" type="file" placeholder="Please provide screenshot of the bug" id="bug_img" accept="image/*"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label class="col-sm-2 col-sm-2 control-label"&gt;Aditional Details&lt;/label&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;textarea class="form-control round-form" placeholder="Provide additionl details here...." id="feedback" tabindex="5" required&gt;&lt;/textarea&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;button type="button" class="btn btn-primary btn-lg btn-block" onclick="getBugReport()"&gt;Submit&lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;  
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;&lt;!-- col-lg-12--&gt;
      &lt;/div&gt;&lt;!-- /row --&gt;
  </code></pre>
  
  <p>This is the java Script code</p>
  
  <pre><code>    function getBugReport() {
  
              var content = document.getElementById("bug_url").value;
              if (content.length &lt; 1) {
                  alert("url field cant be left empty");
                  return false;
              }
  
              content = document.getElementById("bug_des").value;
              if (content.length &lt; 1) {
                  alert("Description field cant be left empty");
                  return false;
              }
  
              if (document.getElementById("bug_img").value == "") {
                  alert("please provide a screenshot of bug");
                  return false;
              }
  
              content = document.getElementById("feedback").value;
              if (content.length &lt; 1) {
                  alert("Message field cant be left empty");
                  return false;
              }
              else {
                      $.getJSON("/Sponsor/sendBugReport/?_bugDes=" + document.getElementById("bug_des").value + "&amp;_bugUrl=" + document.getElementById("bug_url").value + "&amp;_bugDetail=" + document.getElementById("feedback").value, function (data) {
                          document.getElementById("feedback").value = "";
                          document.getElementById("bug_des").value = "";
                          document.getElementById("bug_url").value = "";
                          alert(data);
                      });
              }
          };
  </code></pre>
  
  <p>Here is the controller function</p>
  
  <pre><code>    public JsonResult sendBugReport(String _bugDes, Uri _bugUrl, String _bugDetail)
      {
          try
          {
              if ((_bugDes != null) &amp;&amp; (_bugUrl != null) &amp;&amp; (_bugDetail != null) &amp;&amp; (Request.Files[0] != null))
              {
                  HttpPostedFileBase file = Request.Files[0];
                  string img = @"~\Files\" + file.FileName;
                  file.SaveAs(Server.MapPath(img));
                  string from = "muhammadusama387@gmail.com";
  
                  using (MailMessage mail = new MailMessage(from, "ishtiyar.customer.service@gmail.com"))
  
                  {
  
                      mail.Subject = _bugDes;
                      mail.Body = "URL:\n" + _bugUrl + "\nDetails:\n" + _bugDetail;
                      mail.Attachments.Add(new Attachment(img));
                      mail.IsBodyHtml = false;
                      SmtpClient smtp = new SmtpClient();
                      smtp.Host = "smtp.gmail.com";
                      smtp.EnableSsl = true;
                      NetworkCredential networkCredential = new NetworkCredential(from, "");
                      smtp.UseDefaultCredentials = true;
                      smtp.Credentials = networkCredential;
                      smtp.Port = 587;
                      smtp.Send(mail);
                      return this.Json("Your Bug Report has been Submitted Successfully!!! Thank You", JsonRequestBehavior.AllowGet);
                  }
              }
              else
              {
                  return this.Json("Something went wrong!.... Please provide complete details", JsonRequestBehavior.AllowGet);
              }
          }
          catch (Exception ex)
          {
              return this.Json(ex.ToString(), JsonRequestBehavior.AllowGet);
          }
  
      }
  </code></pre>
  
  <p>thanks</p>