Archive for March, 2012

Latest jQuery

March 16, 2012 Leave a comment

For those that always wants to use the latest jQuery, here’s the link

Categories: AJAX, ASP.NET

Effects of MS11-100 on websites

March 16, 2012 3 comments

On 29 Dec 2011, Microsoft released a security bulletin MS11-100 which attempts to resolve hash collisions vulnerabilities found in


However if you have form pages with > 1000 elements, then you will encounter the following error (for

System.Web.HttpException (0x80004005): The URL-encoded form data is not valid. —> System.InvalidOperationException: Operation is not valid due to the current state of the object.
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()
at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.get_Form()
at System.Web.HttpRequest.get_HasForm()
at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)
at System.Web.UI.Page.DeterminePostBackMode()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

What is happening is that is now checking your Form posted data and if it exceeds a certain threshold it will throw the exception above.


To workaround this, what you can do is to put the following item inside appsettings

<add key="aspnet:MaxHttpCollectionKeys" value="10000" />


By default this value is 1000, but you are free to either limit or give it a larger value

Categories: ASP.NET, IIS

ASP.NET 3.x and above: creating dynamic, or anonymous types

March 2, 2012 Leave a comment

A relatively unknown feature in available since .NET 3.0 is the ability to create dynamic or more correctly anonymous types .

These are typically used in LINQ select scenarios

from p in db.Users

select new (p.Name, p.Email}

This basically creates an anonymous type with Name and Email properties.

With all the new advancements in web technologies, there is this increasing need to have the ability to create objects on the fly so as to pass to web api or to send data across different systems.

Creating an anonymous object in code is pretty simple, below is an example of how you create one

var obj = new {ID=1, Name=”Jeffery”, Email=””};

This basically creates a new object on the fly with the following 3 properties

  1. ID
  2. Name
  3. Email
    For more reading, look at the following links:

Categories: ASP.NET

SignalR–Configuring timeout for connections

March 2, 2012 3 comments

Based on the SignalR wiki, in order to make SignalR work with Azure or load balancers, you will need to tune it such that the polling timeout is lesser than the default polling time of 110 seconds.

To do this, the wiki at tells you to do the following

ASP.NET Example (Global.asax)

 var config = AspNetHost.DependencyResolver.Resolve<IConfigurationManager>(); 
 config.ReconnectionTimeout = TimeSpan.FromSeconds(25);


However if you were to just copy and paste that, you will find that visual studio reports the following 2 errors and wurlies on your code

The name ‘AspNetHost’ does not exist in the current context


The type or namespace name ‘IConfigurationManager’ could not be found (are you missing a using directive or an assembly reference?)




Actually what happens is that the wiki actually forgot to mention that you will actually need to import a few namespaces to global.asax.

They are

  1. SignalR.Configuration – Fixes the IConfigurationManager
  2. SignalR.Hosting.AspNet – Fixes AspNetHost
  3. SignalR.Infrastructure – This is where the Resolve extension reside
      So after adding all these, your global.asax will look like

      <%@ Application Language="C#" %>

      <%@ Import Namespace="SignalR.Configuration" %>

      <%@ Import Namespace="SignalR.Hosting.AspNet" %>

      <%@ Import Namespace="SignalR.Infrastructure" %>

      <script runat="server">

          void Application_Start(object sender, EventArgs e)

              // Code that runs on application startup

              var config = AspNetHost.DependencyResolver.Resolve<IConfigurationManager>();

              config.ReconnectionTimeout = TimeSpan.FromSeconds(25);




    Categories: ASP.NET, Development Tags: