MySQL/ASP.NET Parameter ‘foo’ not found in the collection.

The Error

Parameter ‘foobar’ not found in the collection. at MySql.Data.MySqlClient.MySqlParameterCollection.GetParameterFlexible

Does not mean what it says. It’s somehow related to a documented bug, and fortunately does have a fix. It can occur when arguments in ASP.NET to a MySQL stored procedure are specified in a differing order.

The Solution

In ASP.NET when working with MySQL stored procedures, you MUST specify the parameters in the exact same order and upper/lower casing they appear in your stored procedure.

If this doesn’t fix it, you may have a problem with MySQL Stored Procedure Caching (how to fix). Symptoms here are that MySQL complains about wanting/missing parameters that you just deleted/added/updated being missing or too many.

MS SQL : Cannot Connect to Database After Move

When moving databases from one sever to another, sometimes the users can become locked out. What I mean by this is, the user technically is in the Security>Users folder with all of the correct permissions like they should, but they cannot connect to the server, or they cannot connect to the database itself.

The solution to this is to delete the user, and remake it again.

ASP.NET Specific Error Message Fixes

The files ‘MyScripts.js’ and ‘CodeBehind.cs’ use a different language, which is not allowed since they need to be compiled together.

This error occurred when I put a JavaScript file in my App_Code folder. Simply move it out of that folder.

Both DataSource and DataSourceID are defined on ‘(id)’. Remove one definition.

This is an odd error message that usually means that you are binding a control twice to a datasource. However, if you are binding your control to an object (datatable, for example), that that object is empty and contains no data. Populate your data object and the error message will go away.


(I’ll post more as I find them…)

ASP.NET Apps : Migrating IIS 6 to IIS 7 ; IIS 7 Errors

Migrating from IIS 6 to IIS 7 is a pain in the rear.

From first hand experience, let me tell you, you want to start with a new web.config generated by Visual Studio. There’s a few new sections in there like runtime, and system.webServer. The latter being specifically for IIS7.

I experienced a plethoria of issues in this migration process with my ASP.NET applications. The primary symptoms of IIS 6 to IIS 7 migration troubles are pages that work on some servers but not others, in some browsers but not others, and mysteriously work one day but not another. The primary culprit is usually the web.config.

Here are some issues I discovered and how to fix them.

httpHandlers and httpModules

Server Error in Application “”
Error Summary: HTTP Error 500.22 – Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

Most Likely Causes: This application defines configuration in the system.web/httpModules section.
Most Likely Causes: This application defines configuration in the system.web/httpHandlers section.

FIX: IIS7 does not seem to like httpModules and httpHandlers. In actuallity, it does like them, very much so, however, they are now renamed to ‘modules’ and ‘handlers’ respectively and belong in the system.webServer. You can delete the sections, but then you will probably encounter errors with Validation controls not being called automatically upon postbacks – and you can work around that by manually calling Page.Validate() and if (!Page.IsValid){ return } .

Clientside Javascript (Custom Validators):

I was manually entering “(document.findbyid(‘$ctx200$section1$uxTextbox3’) …” and this had problems with IIS7 that were fine under IIS6. Try using uxTextbox.ClientID instead of hardcoding IDs.

Assemblies Errors

Could not load file or assembly ‘System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.

FIX: The new IIS7 web.config section runtime includes some new ways to use assemblies that include an ‘oldversion’ tag, they look like this:

      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="" newVersion=""/>
          <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="" newVersion=""/>

OR, you can do it the hard way: going to START > RUN > assembly And adding the correct version and public key tokens. If it is already correct and you still get errors, try changing the string to all upper or all lower case letters.

Forms Authentication Problems

SYMPTOMS : The terrible white screen of IE death – “Internet Explorer cannot display this webpage”, no error messages. Inside your Event Log, there will probably be 302 Error messages. Some other symptoms include the page taking over five minutes to load in IE and the IE process taking upwards of 1,800,000 of memory and substantially high CPU from your server (mine was at 55%!).

FIX: The new IIS7 targeted web.config has sections that fix this.

Javascript ScriptHandler/ScriptManager Errors

‘Sys’ is undefined

SYMPTOMS: Custom Javascript and/or CustomValidator can start acting funny or skip validation. Sometimes a page works on one server but not another, in IE but not Firefox, etc, etc.

This can occur when the  web.config does not contain all of the sections for AJAX. Scrutinize your web.config line by line and make sure all of the AJAX sections are included. In my case, I was missing some sections inside of the system.webServer section, and after re-addition, everything works beautifully again.


Related Posts: web.config Hell: Managing Multiple or Mixed Environment web.config’s


System.Web.HttpException Session state has created a session ID …

System.Web.HttpException: Session state has created a session id, but cannot save it because the response was already flushed by the application.

Was struggling with this error for the longest time, implementing role manager then removing it, reading through the login code over and over, scrutinizing our forms authentication and cookies. Finally out of ideas, I decided to google and came across an interesting gem.

The issue was being caused by Session and the page’s life cycle. In a nutshell, when you set Session variables in the Global.asax and then do a Response.Redirect shortly after, you cause problems. Solution: Add a second ‘false’ arguement to your Response.Redirect; ie, make it look like this:

Response.Redirect("default.aspx", false);

If there is a moral of the story it should go something like this: If you cannot figure it out within fifteen minutes, it’s time to Google it.