0

I'm using the ajaxcontroltoolkit and i've run into a problem. Here's my code

<div id="DragDrop" style="margin: 20px auto 20px auto; width: 50%;"center">
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" Width="70%" 
        style="margin:0px auto; min-width:300px;" 
        onuploadcompleteall="AjaxFileUpload1_UploadCompleteAll" 
        onuploadcomplete="AjaxFileUpload1_UploadComplete" />
    <div id="TextUpload" align="center" style="margin: 0px auto 0px auto">
    Text/Url Upload:<asp:TextBox id="Text" runat="server">
    </asp:TextBox>
    </div>
</div>

When I upload my file, I get the red error banner and neither my ajaxfileuploadcomplete nor my ajaxfileuploadallcomplete fire. I searched this on google and none of the fixes i've found apply to this situation.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using AjaxControlToolkit;

public partial class Default : FindLocation
{
    Guid? CanisterID = null;
    Guid? FileID = null;
    string path = "";
    string name;
    string type;
    int size;
    protected void Page_Load(object sender, EventArgs e)
    {
        path = Find();
    }
    protected void AjaxFileUpload1_UploadCompleteAll(object sender, AjaxControlToolkit.AjaxFileUploadCompleteAllEventArgs e)
    {
        throw new Exception();
    }
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        throw new Exception();
        // Generate file path
        string filePath = "~/Images/" + e.FileName;

        // Save upload file to the file system
        ajaxUpload1.SaveAs(MapPath(filePath));
        name = e.FileName;
        type = e.ContentType;
        size = e.FileSize;

        AjaxFileUpload1.SaveAs(MapPath(path));
        DataClassesDataContext db = new DataClassesDataContext();
    }
}

I added these to my web.config

  <system.webServer>

        <validation validateIntegratedModeConfiguration="false"/>
        <handlers>
          <add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler,            AjaxControlToolkit"/>
        </handlers>
      </system.webServer>
      <system.web>
        <httpHandlers>
          <add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
        </httpHandlers>

I put this at the top of the page

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

And also I don't have any querystrings on this page. Any idea what's wrong? ![Heres a picture of the error][1]

https://i.stack.imgur.com/k7zh8.jpg

2 Answers2

0

The problem is most likely due to that you are uploading a file, which size exceeds the allowed one of 4 MB. You can increase the default one of .NET by setting the MaxRequestLength web.config attribute to bigger value. See these articles for more information: Maximum value of maxRequestLength? and While uploading large files getting error

Community
  • 1
  • 1
Rumen Jekov
  • 1,665
  • 2
  • 17
  • 19
  • nope it still failed while uploading a 2 byte text file. Thanks for the reply though, i was planning to upload big files eventually so this will definitely save me from future errors. – user3525258 Jun 30 '14 at 00:13
  • Check out this thread because it could be helpful http://stackoverflow.com/questions/17051845/ajaxfileupload-error. If it does not help, try to provide more information about the real error as shown in this thread https://ajaxcontroltoolkit.codeplex.com/workitem/27416 – Rumen Jekov Jun 30 '14 at 06:14
  • Yeah that actually describes my issue perfectly except those fixes didn't solve it for me. I'd be really happy if someone could at least show me a working C# example like on this page http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/AjaxFileUpload/AjaxFileUpload.aspx I havent been able to find any with google – user3525258 Jun 30 '14 at 21:08
0

For your convenience I've created a sample web site which demonstrates how to upload files via the https://onedrive.live.com/?cid=f8992524aeae67e6&id=F8992524AEAE67E6%21107&authkey=! The web.config is taken from the default AjaxToolkit demo project.

You can see how the solution works in the following video: http://screencast.com/t/fF4N6MeGc70c

Best regards, Rumen

Rumen Jekov
  • 1,665
  • 2
  • 17
  • 19
  • Item no longer exists. I'm facing the same issue as OP, and the other suggestions also aren't helping me. – Andrew S Jun 27 '18 at 17:15