title: AjaxFileUpload from AjaxToolkit Not Working
body: <p>I am getting the following error when trying to upload a file:</p>
  
  <p>System.Web.HttpExceptionThis method or property is not supported after HttpRequest.Form, Files, InputStream, or BinaryRead has been invoked.</p>
  
  <p>The call stack is:</p>
  
  <pre><code>System.Web.HttpException (0x80004005): This method or property is not supported after HttpRequest.Form, Files, InputStream, or BinaryRead has been invoked.
    at System.Web.HttpRequest.GetInputStream(Boolean persistEntityBody, Boolean disableMaxRequestLength)
    at AjaxControlToolkit.AjaxFileUploadHelper.Process(HttpContext context)
    at AjaxControlToolkit.AjaxFileUploadHandler.ProcessRequest(HttpContext context)
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)
  </code></pre>
  
  <p>The App Pool is configured for integrated mode.
  I am using Framework 4.5.
  I am using the most up-to-date version of the Ajax Toolkit.</p>
  
  <p>This error occurs before the OnUploadComplete event is fired.</p>
  
  <p>Here are the code extracts...</p>
  
  <p>extract 1:</p>
  
  <pre><code>&lt;form id="Form1" class="theForm" enctype="multipart/form-data" runat="server"&gt;
      &lt;atk:ToolkitScriptManager EnableHistory="true" ID="tsm" runat="server"&gt;
      ....
  &lt;/form&gt;
  </code></pre>
  
  <p>extract 2:</p>
  
  <pre><code>&lt;ajaxToolkit:AjaxFileUpload ID="afuDoc" MaximumNumberOfFiles="1" OnUploadComplete="afuDoc_UploadComplete" ThrobberID="imgLoading"runat="server" /&gt;
  </code></pre>
  
  <p>extract 3:</p>
  
  <pre><code>protected void afuDoc_UploadComplete(Object sender, AjaxFileUploadEventArgs e)
  {
      if (afuDoc.IsInFileUploadPostBack &amp;&amp; e.State == AjaxFileUploadState.Success)
      {
          afuDoc.SaveAs(@"~/Uploads/" + e.FileName);
      }
  }
  </code></pre>
  
  <p>extract 4 (Web.config inside system.web):</p>
  
  <pre><code>&lt;httpHandlers&gt;
      &lt;add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" /&gt;
  &lt;/httpHandlers&gt;
  </code></pre>
  
  <p>extract 5 (Web.config inside system.webServer):</p>
  
  <pre><code>&lt;validation validateIntegratedModeConfiguration="false"/&gt;
  &lt;handlers&gt;
    &lt;add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" /&gt;
  &lt;/handlers&gt;
  &lt;security&gt;
    &lt;requestFiltering&gt;
      &lt;requestLimits maxQueryString="4096" maxUrl="4096" maxAllowedContentLength="4294967295" /&gt;
    &lt;/requestFiltering&gt;
  &lt;/security&gt;
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p>UPDATE: </p>
  
  <p>Elmah actually catches another error along with the one that's mentioned above.  The second error is as follows.</p>
  
  <p>System.IO.DirectoryNotFoundExceptionCould not find a part of the path 'C:\Windows\TEMP_AjaxFileUpload\D8FC028F-3950-94BD-6205-8F2EF7DC43B7'.</p>
  
  <p>Call stack is:</p>
  
  <pre><code>System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---&gt; System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Windows\TEMP\_AjaxFileUpload\D8FC028F-3950-94BD-6205-8F2EF7DC43B7'.
     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
     at System.IO.FileSystemEnumerableIterator`1.CommonInit()
     at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
     at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption, Boolean checkHost)
     at System.IO.Directory.InternalGetFiles(String path, String searchPattern, SearchOption searchOption)
     at AjaxControlToolkit.AjaxFileUpload.XhrDone(String fileId)
     at AjaxControlToolkit.AjaxFileUpload.OnPreRender(EventArgs e)
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Control.PreRenderRecursiveInternal()
     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
     at System.Web.UI.Page.HandleError(Exception e)
     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
     at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
     at System.Web.UI.Page.ProcessRequest()
     at System.Web.UI.Page.ProcessRequest(HttpContext context)
     at ASP.main_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\msdebug\3d598d4d\d90118d\App_Web_frmymo1s.1.cs:line 0
     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)
  </code></pre>