user3350067
user3350067

Reputation: 75

AjaxFileUpload not working in iis 7.5 and Later

I am using AjaxFileUpload Control to upload multiple files at a time and for Drag & Drop functionality. Its not working in IIS7.5 and later versions .

Here is My Code:

.aspx Page :

             <body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server">
</asp:ToolkitScriptManager>
<table width="100%">
    <tr>
        <td width="15%" height="200px">
        </td>
        <td width="60%" height="200px">
            <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" OnUploadComplete="AjaxFileUpload1_UploadComplete"
                Height="200px" />                
        </td>
        <td width="15%" height="200px">
        </td>
    </tr>
</table>
<asp:Label ID="lblError" runat="server"></asp:Label>
</form>

.CS Code:

       protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        try
        {
            string Path = ConfigurationManager.AppSettings["UploadPath"].ToString();
            string filePath = Path + Convert.ToString(e.FileName);
            AjaxFileUpload1.SaveAs(filePath);
        }
        catch (Exception ex)
        {
        }
    }

Upvotes: 1

Views: 4104

Answers (2)

CicheR
CicheR

Reputation: 409

We was having the same problem.

The control stop working when we update our sites from Framework v2 to v4.

We are using pool on "Classic" mode, that is the problem, if we change the pool's mode to "Integrated", the problem disappears and the control work just fine.

As we can't change the pool mode, we went to look for another solution... and we found it!!!

We add the option preCondition="integratedMode" to the handler's registration in Web.Config and PROBLEM SOLVED!! :)

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

Upvotes: 2

Banana
Banana

Reputation: 7483

add the following lines to your web.config:

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

Upvotes: 1

Related Questions