locked
AjaxFileUpload runtime Error RRS feed

  • Question

  • User1193679271 posted

    hi all

    I am using AjaxFileUpload for upload image. in asp.net c#

    my code at below

    in Default.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="AjaxUploadImage_Default" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        
            <cc1:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
                AllowedFileTypes="jpg,jpeg,png,gif"
                MaximumNumberOfFiles="10"
                OnUploadComplete="File_Upload"
                Width="500px" />
    
        </div>
        </form>
    </body>
    </html>

    in Default.cs

    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    using AjaxControlToolkit;
    
    public partial class AjaxUploadImage_Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    
        protected void File_Upload(object sender, AjaxFileUploadEventArgs e)
        {
            string filename = e.FileName;
            string strDestPath = Server.MapPath("~/images/");
            AjaxFileUpload1.SaveAs(@strDestPath + filename);        
        } 
    
    }

    in Web.Config

    <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.5">
          <assemblies>
            <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          </assemblies>
        </compilation>
        <httpRuntime targetFramework="4.5"/>
      </system.web>
    </configuration>

    error is like at below

    Unhandled exception at line 3422, column 28 in localhost:..

    0x800a139e - JavaScript runtime error: Sys.ArgumentException: Cannot deserialize empty string.

    Parameter name: data

     

    Regards

    DigiNaz

    Friday, July 3, 2015 10:31 AM

Answers

  • User1724605321 posted

    Hi diginaz ,

    Thanks for your post .

    The AjaxFileUpload control uses an HTTP Handler named AjaxFileUploadHandler.axd This handler has the type AjaxControlToolkit.AjaxFileUploadHandler. You must add this handler to your Web.Config file in order for the AjaxFileUpload control to work.

    Here's the Web.Config configuration that you must add:

    <system.web>
        ....
        <httpHandlers>
            <add verb="*" path="AjaxFileUploadHandler.axd"
              type="AjaxControlToolkit.AjaxFileUploadHandler, 
              AjaxControlToolkit"/>
        </httpHandlers>
    </system.web>

    For IIS7:

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

    For more information ,please refer to link below:

    http://ajaxcontroltoolkit.devexpress.com/AjaxFileUpload/AjaxFileUpload.aspx

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 6, 2015 1:09 AM

All replies

  • User1724605321 posted

    Hi diginaz ,

    Thanks for your post .

    The AjaxFileUpload control uses an HTTP Handler named AjaxFileUploadHandler.axd This handler has the type AjaxControlToolkit.AjaxFileUploadHandler. You must add this handler to your Web.Config file in order for the AjaxFileUpload control to work.

    Here's the Web.Config configuration that you must add:

    <system.web>
        ....
        <httpHandlers>
            <add verb="*" path="AjaxFileUploadHandler.axd"
              type="AjaxControlToolkit.AjaxFileUploadHandler, 
              AjaxControlToolkit"/>
        </httpHandlers>
    </system.web>

    For IIS7:

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

    For more information ,please refer to link below:

    http://ajaxcontroltoolkit.devexpress.com/AjaxFileUpload/AjaxFileUpload.aspx

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 6, 2015 1:09 AM
  • User1193679271 posted

    hello Nan Yu

    thanks

    with best regards

    DigiNaz

    Monday, July 6, 2015 6:53 AM