title: IIS/ASP.NET - Request.Files Empty In Production
body: <p>I am uploading a file to an ASP.NET ASPX page using HTTP POST from an Android phone. The process works perfectly when the web server used is the development server (Visual Studio 2013, IIS Express). The Request.Files collection contains my file, and all is right with the world.</p>
  
  <p>The same code, running in production under IIS 7.5, still returns a response code of 200 (not 405!), but the Request.Files collection is completely empty.</p>
  
  <p>For the life of me, I cannot figure out why. If the verb was being denied, I should have received a 405 code.</p>
  
  <p>This the the Java code being executed on the phone:</p>
  
  <pre><code>URL postURL = new URL("redacted");
  
  // Create the HTTP connection set our properties.
  conn = (HttpURLConnection) postURL.openConnection();
  conn.setDoInput(true);
  conn.setDoOutput(true);
  conn.setUseCaches(false);
  conn.setRequestMethod("POST");
  conn.setRequestProperty("Connection", "Keep-Alive");
  conn.setRequestProperty("ENCTYPE", "multipart/form-data");
  conn.setRequestProperty("Content-Type", "text/plain");
  conn.setRequestProperty("uploaded_file", file.getName());
  
  // Set up our stream writer.
  dos = new DataOutputStream(conn.getOutputStream());
  
  // Write the opening.
  dos.writeBytes(twoHyphens + boundary + lineEnd);
  dos.writeBytes("Content-Disposition: form-data; name="
      + file.getName() + ";filename=" + file.getName()
      + ";Content-Type: text/plain" + lineEnd);
  
  dos.writeBytes(lineEnd);
  
  // Grab our file and the stream object.
  fileInputStream = new FileInputStream(file);
  
  bytesAvailable = fileInputStream.available();
  
  bufferSize = Math.min(bytesAvailable, maxBufferSize);
  buffer = new byte[bufferSize];
  
  bytesRead = fileInputStream.read(buffer, 0, bufferSize);
  
  // Write the file contents.
  while (bytesRead &gt; 0) {
      dos.write(buffer, 0, bufferSize);
      bytesAvailable = fileInputStream.available();
      bufferSize = Math.min(bytesAvailable, maxBufferSize);
      bytesRead = fileInputStream.read(buffer, 0, bufferSize);
  }
  
  // Finish up writing our file.
  dos.writeBytes(lineEnd);
  dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
  
  // Close our stream objects.
  fileInputStream.close();
  dos.flush();
  dos.close();
  </code></pre>
  
  <p>Is there some setting in IIS that I'm missing that's preventing that data from being propagated? Every example I've looked at for using HTTP POST to upload a file from Android without the Apache libs looks just like this.</p>