Microsoft KB Archive/321023

= FIX: Cannot Use Null Key Values for Session Variables in SQL Server Mode or State Server Mode =

Article ID: 321023

Article Last Modified on 1/19/2004

-

APPLIES TO


 * Microsoft ASP.NET 1.0

-



This article was previously published under Q321023



SYMPTOMS
If you use null key values for session variables in the State Server session state mode or SQL Server session state mode in ASP.NET, you receive the following error message:

Server Error in ' ' Application.

Value cannot be null. Parameter name: value

Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: value



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in ASP.NET (included with the .NET Framework) 1.1.



MORE INFORMATION
Microsoft recommends that you not use null key values for session variables.

Steps to Reproduce the Behavior
 Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project. Click Visual C# Projects under Project Types, and then click ASP.NET Web Application under Templates.  Add the following code in the code-behind file (WebForm1.aspx.cs) in the Page_Load event handler: Session[null]=&quot;testSession&quot;;   In the Web.config file, modify the mode attribute in the  element to use SQL Server or State Server mode. Make sure that the user id account has permissions on the database. For example: 

-or-

<sessionState mode=&quot;StateServer&quot; stateConnectionString=&quot;tcpip=127.0.0.1:42424&quot; sqlConnectionString=&quot;data source=127.0.0.1;user id= ;password= &quot; cookieless=&quot;false&quot; timeout=&quot;20&quot; /> NOTE: To use State Server session state mode, you must start the ASP.NET state service. To use SQL Server session state mode, you must configure Microsoft SQL Server for this purpose. </li> Build the project.</li> Open the WebForm1.aspx page in your browser. You receive the error message that is listed in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">