Microsoft KB Archive/321023

From BetaArchive Wiki

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 '/SessionNullKB' 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

  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. Click Visual C# Projects under Project Types, and then click ASP.NET Web Application under Templates.
  4. Add the following code in the code-behind file (WebForm1.aspx.cs) in the Page_Load event handler:

    Session[null]="testSession";
                        
  5. In the Web.config file, modify the mode attribute in the <sessionState> element to use SQL Server or State Server mode. Make sure that the user id account has permissions on the database. For example:

    <sessionState 
                mode="SQLServer"
                stateConnectionString="tcpip=127.0.0.1:42424"
                sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<password>"
                cookieless="false" 
                timeout="20" 
    />
                            

    -or-

    <sessionState 
                mode="StateServer"
                stateConnectionString="tcpip=127.0.0.1:42424"
                sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<strong password>"
                cookieless="false" 
                timeout="20" 
    />
                            

    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.

  6. Build the project.
  7. Open the WebForm1.aspx page in your browser. You receive the error message that is listed in the "Symptoms" section.


REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

307598 INFO: ASP.NET State Management Overview



Additional query words: kbwamState kbwamConfig Out-of-Process Mode

Keywords: kbbug kbfix kbstate kbconfig KB321023