104 posts

Input string was not in a correct format error when clicking ImageButton in IE 10 or higher

First of all, this is not a new issue. If you have an old .NET web form, especially prior to .NET 4.5, with an ImageButton in a UpdatePanel, then when you click on the ImageButton in IE 10 or higher browser, then you will encounter an error: The input string was not in a correct format Without going into the details of the root cause, I will just list the fixes here: Fix 1: Simply upgrade […]

Duplicate headers received from server

This error is very common to ASP.NET developers. If you have a web application that generates some file on the fly then prompts the user to download the file, then you may encounter “duplicate headers received from server” error. Most likely the web application will use Response.AddHeader() method to push the file to the browser for downloading, something like this: Response.AddHeader(“Content-Disposition”, “attachment;filename=” + outputFileName ); If the variable outputFileName contains comma, then you will get […]

HTML Label Tag Causes Mysterious Behavior of ASP.NET Button

Recently, because of my ignorance of the HTML label tag, I encountered a very weird problem. I have a page like this: And the problem is no matter which button I click, the “Save Student Record” button is always fired. Even I set a break point on the button clicked event handler of the button “New Search”, the break point never gets triggered. If I switch the Save Student Record button and the New Search […]

Simulate UpdateProgress when Using ASP.NET FileUpload Control

[UPDATE] For those who complain that my example is not working, it is most likely because you don’t know CSS very well. Here are things you need to check if you try to follow my example: 1. Do NOT use UpdatePanel 2. Make sure your image “src” is pointing to your loading gif file. You cannot just copy and paste my code and expect the image to show up 3. Add the following two CSS classes […]

AJAX request timeout error

The default value of AJAX postback is 90 seconds, so if you have a long asynchronous postback, you will get an error as this: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out. The fix is to change the default timeout value to a larger value in your ScriptManger’s AsyncPostBackTimeout property (10 minutes as below): <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="600"> </asp:ScriptManager>

Invalid Parameter Binding error when using Oracle ODP.NET TableAdapter

If you use Oracle ODP.NET in Visual Studio 2010 (or earlier version) to create a DataTable by using TableAdapter wizard, you may get an Invalid Parameter Binding error if there is a parameter in your query. For example, this simple select query below can cause the error: select * from Person where personId=:person_uid The cause is strange because ODP.NET cannot recognize the parameter’s DbType and thus sets the DbType of the parameter to Object, so […]

ASP.NET Forms Authentication Blocks Images and CSS Files

If you use the ASP.NET Forms Authentication in your web application that runs on IIS 7 or above with the integrated pipeline application pool, you may find that the images and the styles of your application are not displayed until you are logged in (authenticated). If you encounter this problem, here is the solution to fix it. First, let me take one step back to explain why the problem happens. If you look at your […]

Invalid length for a base-64 char array error

I have been working on a project that needs to encrypt and decrypt the query string of a page, and I get the “invalid length for a base-64 char array” error intermittently. Thanks to this post (the third reply by Kagisho), I got the error fixed. But what caused this error? And why does it not happen all the time? Here is my encryption function and decryption function: private string EncryptString(string inString) { RijndaelManaged sysAlg […]

Batch update your Web.config to workaround ASP.NET security vulnerability

[UPDATE]: There is no need for using this tool to update your web applications, because Microsoft has released the official ASP.NET security fix through Windows Update: You may have already known the newly discovered ASP.NET security vulnerability, and the suggested workaround is to modify your Web.config file until Microsoft releases a security path, as mentioned in Scott’s blog: I hope you have already updated your application according to the workaround. However, what if […]