Wednesday, September 12, 2007

ASP.NET Session State Variables NULL is the same as 0 for an integer

I set a session variable to Integer 0 and then tried to read it back in to an integer.

The result was a NULL value.

Writing the value as a string and then converting it when reading it back in solved the problem. I assume that 0 is the default initial value for an integer and so ASP did not bother to save it, although I haven't checked this. This would mean that other types would have the same problem.

No comments: