Wednesday 2 June 2010

The state information is invalid for this page and might be corrupted

This is a nice gotcha for load balanced ASP.NET sites:
If you have a dynamically compiled ASP.NET website, and you put objects from a dynamic part into the ViewState, you'll be in for a NASTY surprise when you move to a load-balanced scenario.
Basically, you'll occasionally get exceptions with the message "The state information is invalid for this page and might be corrupted" as the compiled types on the different servers are different.
Either:
  • Move the types you put into ViewState into a compiled assembly (dll for old-schoolers ), or,
  • Only use primitive types (int, byte, string, char, etc) in the ViewState. Enums do not count as primitive types.

Friday 15 January 2010

Another reason to use log4net rather than rolling your own logging framework

Exception during StringFormat: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. Served {0} coupons out of {1} for {3}{296366, 100, Campaign{id#891e4cb2-da21-456b-bb5e-38cfbf9a90db}}