Showing posts with label Errors. Show all posts
Showing posts with label Errors. Show all posts

Monday, August 6, 2012

Unhandled Exception: "The file attached is invalid" with AsyncFileUploader and .NET Framework 4

 

I upgraded my ASP.NET framework from 3.5 to 4 recently, and encountered a host of problems.

I knew the problem was due to the upgrade because I had not changed my code, and yet, there were parts of the system that went haywire with seemingly esoteric errors.

Today, I got the error below when I tried to upload images on a web page that was working perfectly before.

2012-08-06_102203

 

Fortunately, the error is easy to solve.  I just followed the tip from ndkjava given on the ASP.NET forum.

Basically, what you need to do is to locate the control on the markup code and add this attribute to it.

ClientIDMode="AutoID"

For example, this is how my code looks like after adding it.

<asp:AsyncFileUpload ClientIDMode="AutoID" ID="AsyncFileUpload1" runat="server"  onuploadedcomplete="AsyncFileUpload1_UploadedComplete" />

Everything seems to work marvellously after that! :)


ps. If you want to download the latest version of the FileAsyncUpload which is in the ASP.NET AJAX Control Toolkit 4, you can get it at CodePlex here (updated 24 Jun 2012).


For tutorials on how to use the AJAX Control Toolkit FileAsyncUpload control,  you can find one here.

Wednesday, August 1, 2012

How to solve “Error: Unrecognized element 'folderLevelBuildProviders'”


This morning, I created a ASP.NET using the default application and not touching any of the default code, I tested it successfully with the built-in web server Visual Studio 2010.  Next, I happily clicked on the “Publish Web Site” menu item and deployed it on the local IIS.
Since I did not even do anything to the default code, I thought there would be no problem when I try to call this web application from another computer.  To my dismay,  when I tried to view the site I see an "500 - Internal server error."
So I checked out the IIS manager and tried to click on the “.NET Compilation” icon.  And encountered this error  "Unrecognized element 'folderLevelBuildProviders' ".
Well, “fortunately”, it seems that this is a common problem when and tried to and solved this using the tip from stackoverflow.
So the solution is quite simple, you register the aspnet to recognise the Framework 4.0 like this:
2012-08-01_100301
What you need to make sure is that, depending on whether you are on a 32 bit or 64 bit machine, the command differs abit.
For 32 bit machine
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis –i
For 64 bit machine
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis –i

How to solve “There is a duplicate ‘system.web.extensions/scripting/scriptResourceHandler’” error

 

I got this error after I ran a “C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis –i” command.

Apparently, it happens when you run an older version of ASP.NET application on an IIS server that has been upgraded to use the ASP.NET Framework 4.0.

I found the way to solve this problem via Brad Kingsley’s tip .

All you need to do is to edit your web.config and comment out the section “system.web.extensions” as follows.  It worked well for me, and I hope it does for you too! :)

2012-08-01_102555

Wednesday, May 16, 2012

How to solve the "The type or namespace 'Packaging' does not exist in the namespace 'System.IO'" error

If you encounter this error "The type or namespace 'Packaging' does not exist in the namespace 'System.IO', here's an easy way to solve it.

Just locate the
<assemblies>
 tag in your web.config file and add this line.  It should resolve the compilation errors straightaway.
<add assembly="WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Friday, January 7, 2011

I came across this error when I was coding a file that updated a table using SqlDataSource with a Stored Procedure.

""Procedure or function "  .... "has too many arguments specified"

Googled for the keywords above and I found this suggestion to my problem from phynix at forums.asp.net.

Adding the code solved my problem totally! ^.^

Thank you phynix!


Add an event handle for your SqlDataSource's Updating event:
for example:
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
 protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
 {
  DbParameterCollection CmdParams = e.Command.Parameters;
  ParameterCollection UpdParams = ((SqlDataSourceView)sender).UpdateParameters;
  Hashtable ht = new Hashtable();
  foreach (Parameter UpdParam in UpdParams)
      ht.Add(UpdParam.Name, true);
  for (int i = 0; i < CmdParams.Count; i++)
  {
      if (!ht.Contains(CmdParams[i].ParameterName.Substring(1)))
          CmdParams.Remove(CmdParams[i--]);
  }
 }