top
logo


Home Windows C# ASP.NET Ajax Control Toolkit AsyncFileUpload - The file attached is invalid

Ajax Control Toolkit AsyncFileUpload - The file attached is invalid

PDF Print E-mail
(3 votes, average 3.67 out of 5)
Written by Alex Balyuk   
Tuesday, 17 August 2010 21:58

Recently I was working on conversion of a social network project from ASP.NET 3.5 to ASP.NET 4.0. Everything went pretty smoothly except for AjaxControlToolkit Asynchronous File Upload control. Basically the uploading of file did not work, on the staging server nothing happening during the file upload... but in debug mode the following error was thrown ((AjaxControlToolkit.AsyncFileUpload)(sender)).FileContent' threw an exception of type 'System.NullReferenceException' with status message "The file attached is invalid." 

It seemed pretty odd because the code was not modified and everything functioned on .NET 3.5. This is .NET version incompatibility with AjaxControlToolkit.

aspnet-4-ayncfileupload-error

Solution for this error is pretty easy, but to find solution on your own is a time consuming nightmare. I spend at least few hours reading about .NET 3.5 and .NET 4.0 differences until figured this one out.

To fix it do the following:

  1. Open Web.config file
  2. Add the following attributes to the page element
    controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"

To summarize, your opening page element in the Web.config should look like this

<pages enableEventValidation="false" validateRequest="false" viewStateEncryptionMode="Never"  controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">

Last Updated on Thursday, 19 August 2010 15:48
 

Add comment


Security code
Refresh



Copyright © 2012 (bool) cast.com. All Rights Reserved.
Joomla!Joomla! is Free Software released under the GNU/GPL License.GNU/GPL License.

bottom
top
Site Map | Contact Us

bottom