Microsoft KB Archive/284466

= PRB: Session_OnStart Event Enters Infinite Loop =

Article ID: 284466

Article Last Modified on 5/8/2001

-

APPLIES TO


 * Microsoft Active Server Pages 4.0

-



This article was previously published under Q284466



SYMPTOMS
When you use the Response.Redirect method in the Session_OnStart event, the event enters an infinite loop.



CAUSE
When a user browses the first .asp page in a Web site, the Global.asa file in that virtual directory fires the Session_OnStart event. If the user is redirected to another page in the same application, Global.asa fires the Session_OnStart event again. This behavior continues until a session is initialized. As a result, if the user is redirected before the session is initialized, the server continually fires a new session.



RESOLUTION
To resolve this problem, provide code that initializes the session prior to redirection. For example:  Sub Session_OnStart 'Add code here to initialize the session Session(&quot;init&quot;) = True Response.Redirect(&quot;somepage.asp&quot;) End Sub 



Steps to Reproduce Behavior
 Add three pages, named Page1.asp, Page2.asp, and Global.asa, to an Internet Information Server (IIS) application.  Paste the following code in the Global.asa file:  Sub Session_OnStart Response.Redirect(&quot;Page2.asp&quot;) End Sub   In your Internet browser, browse to Page1.asp. The browser is caught in a loop between Page1.asp and Page2.asp.</ol>

Keywords: kbscript kbwebserver kbaspobj kbprb KB284466

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.