Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to maintain the ASP.NET session state


View products that this article applies to.

Introduction

The Microsoft ASP.NET session state is process-dependent. Anything that affects the process may result in a lost session state. This article discusses how to maintain the ASP.NET session state.

↑ Back to the top


More information

The following are two common scenarios in which the session may behave unpredictably:
  • When you click a hyperlink in an application that is hosting the WebBrowser control, a new page opens in Internet Explorer. In this scenario, the session cookie is lost, and you may have to log on again. This behavior occurs because Internet Explorer is a different process than the application process. A session cookie cannot be shared between processes.

    To maintain the session state in this scenario, you can use the NewWindow2 event to open the new page in another form in the application. This event is triggered by the WebBrowser control. For more information about how to use the NewWindow2 event, click the following article number to view the article in the Microsoft Knowledge Base:
    311282 How to use the WebBrowser control NewWindow2 event in Visual Basic .NET
  • You open an ASP.NET-connected application in Internet Explorer. The application sends a Microsoft Outlook e-mail message that contains a hyperlink. In this scenario, you assume that the application will obtain a new session when you click the hyperlink in Outlook. However, Outlook uses the same session as the ASP.NET-connected application uses. This behavior occurs because the new page that is opened in Internet Explorer uses the existing Internet Explorer process instead of creating a new process. This behavior is by design because using an existing process saves resources and time.

    To maintain the system state in this scenario, you can use a query string to store the state of the application. For more information about how to store a state in an active server pages application, click the following article number to view the article in the Microsoft Knowledge Base:
    175167 How to store state in Active Server Pages applications

↑ Back to the top


References

For more information about the ASP.NET session state, visit the following Microsoft Web site:

↑ Back to the top


Properties

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.

↑ Back to the top


Keywords: KB932474, kbhowto, kbinfo

↑ Back to the top

Article Info
Article ID : 932474
Revision : 2
Created on : 2/16/2007
Published on : 2/16/2007
Exists online : False
Views : 447