title: Upload file to aspx site with WebClient
body: <p>I have an aspx website and I'd like to upload a file to it. The file is being processed later, so I need to support some extra information with it.</p>
  
  <p>This is the website I have to far:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Upload.aspx.cs" Inherits="ABC.Web.Upload" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="Form1" method="post" enctype="multipart/form-data" runat="server"&gt;
      &lt;input type="file" id="File1" name="File1" runat="server" /&gt;
      &lt;input type="text" id="FileId" name="FileId" runat="server" /&gt;
      &lt;input type="submit" id="Submit1" value="Upload" runat="server" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This (and the code behind) works very well when using a browser and clicking through the form. But I want to upload the file using the <strong>WebClient</strong> from C# code. I don't have to use the WebClient, so I am open to other suggestions. I can also modify the upload.aspx to suit me, there is no requirement that it works from a browser, but this is the only example I've got working. </p>
  
  <p>Looking at fiddler (I just started using it, so I probably have missed it) I could not figure out how I would create such a request from code. </p>
  
  <p>At the moment when using the WebClient I am specifying the address and the local filename. I have a breakpoint in the code behind in my website but the File1 and FileId are not set (as expected). </p>
  
  <p><strong>How do I have to modify the website and how do I have to use the WebClient to get the upload working?</strong></p>
  
  <p>EDIT: Just found out about the Request.Files, that will give me the file, but how about the other fields?</p>