Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms
of Use |
FIX: Cannot Use Null Key Values for Session Variables in SQL Server Mode or State Server Mode
This article was previously published under Q321023
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
Value cannot be
null. Parameter name: value
System.ArgumentNullException: Value cannot be null. Parameter name: value
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
Microsoft recommends that you not use null key values for
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:
- 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:
sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<password>"
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.
sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<strong password>"
- Build the project.
- Open the WebForm1.aspx page in your browser. You receive
the error message that is listed in the "Symptoms" section.
For additional information, click
the article number below to view the article in the Microsoft Knowledge Base:
INFO: ASP.NET State Management Overview
Article ID: 321023 - Last Review: January 19, 2004 - Revision: 5.1
|kbfix kbbug kbconfig kbstate KB321023|Retired 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
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