AjaxfileUpload error

I’m trying to implement a simple ajaxtoolkit fileupload control and every time I click “Upload” all I get is an error. I tried placing breakpoint in the “AjaxFileUpload1_UploadComplete” function but it won’t even get fired.. (maybe because upload isn’t complete yet?) what should I do to make it work?

here is the error:
enter image description here

here is my aspx:

 <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">

       <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
            onuploadcomplete="AjaxFileUpload1_UploadComplete" ThrobberID="myThrobber" MaximumNumberOfFiles="10" AllowedFileTypes="jpg,jpeg"/>


and here is the funcion behind:
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        string id = "038191904";
        Directory.CreateDirectory(Server.MapPath("~/App_Data/" + id + "/scanned_docs/"));
        string filePath = "~/Member_Data/" + id + "/images/";
        string path = filePath + e.FileName;
        AjaxFileUpload1.SaveAs(Server.MapPath(filePath) + e.FileName);

        //db1.insert_pic_slide(id, path);



Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

This was happening to me, and I did two things to fix it:

1) Update your site’s web.config file to contain entries for the following:

    <add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
    <add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />

2) If the page you’re uploading from is inside a folder with it’s own web.config with deny anonymous authorization rules, make sure you add an allow for the AjaxFileUploadHandler like so:
<location path="AjaxFileUploadHandler.axd">
      <allow users="*"/>

Method 2

Just going to add this troubleshooting advice for the AjaxFileUpload control. If you added all of the web.config statements as recommended on this page and still get an error on upload, swap out the AjaxFileUpload control with the Ajax AsyncFileUpload control. The code between the two are almost identical to use and it will only take a minute to swap them out.

The AjaxFileUpload captures errors and it is very hard to find the real reason of the upload problem. The AsyncFileUpload will throw the actual error.

I spent a whole afternoon digging through forums on the AjaxFileUpload for what looked like a directory permissions/temp folder issue. I actually had a database error that I was able to fix 15 minutes after I swapped to the AsyncFileUpload and ran into the real problem.

The error that the AjaxFileUpload was throwing when I debugged in FireFox was:

ajaxfileupload error raising upload complete event and start new upload

And the IIS error was error 500.

Keep in mind it was just a database error. I added a column locally that I forgot to add to the hosting database, so it worked locally for me, but threw an error on the hosting server when I deployed.

Close to a whole day of work on something that should have taken 15 minutes to fix.

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x