Microsoft Knowledge Base Email Alertz

(321023) - 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....

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 321023 - Last Review: January 19, 2004 - Revision: 5.1

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

This article was previously published under Q321023

On This Page

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  (http://kbalertz.com/Feedback.aspx?kbNumber=307598/EN-US/ ) INFO: ASP.NET State Management Overview

APPLIES TO
  • Microsoft ASP.NET 1.0
Keywords: 
kbfix kbbug kbconfig kbstate KB321023
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate