opswordfish
opswordfish

Reputation: 21

Classic ASP Sessions being lost when going to a new page

I have looked around on the internet for a length of time and I cannot find the answer to a Classic ASP issue that I have. I have been tasked with getting an old Classic ASP solution working locally, which has proved challenging due to the fact that I have very little knowledge of the application or classic ASP itself.

I have managed to setup debugging and what appears to happen is the session variables get set but when navigating to a new page the session variables are gone on and the sessionid field has been incremented. I think the reason for this is because the cookie is not being set. I have tried this on Chrome, IE, Firefox and Opera and I get the same issue each time.

The difference in server setup between my local machine and the web server where the live application is hosted has made this especially difficult as I cannot as easily compare IIS configurations. My local machine has IIS 7.5 installed and the webserver has IIS version 6 installed. I have also tried creating my own application and here the session was working correctly between requests, which leads me to believe that this is an IIS configuration issue or an issue with the application. I have also placed breakpoints on anywhere where Session.Abandon occurs and these breakpoints are not being hit

Any help would be greatly appreciated

Alex

Upvotes: 2

Views: 2298

Answers (3)

Marek Marciniak
Marek Marciniak

Reputation: 144

What about the number of Worker process? By default there should be 1 worker process per application pool. If there are more worker process - sessions can also be lost between them.

In IIS check the following setting in your application pool which handles your website: "Maximum number of worker process".

Upvotes: 1

Robert S
Robert S

Reputation: 496

Your application is likely throwing errors and/or recycling the application pool, or the links/forms/redirects you are using are crossing domain boundaries (x.com to y.com, then back to x.com) and thus creating sessions on the wrong domains.

See: https://blogs.msdn.microsoft.com/akshayns/2008/09/29/common-reasons-for-the-session-loss-issue-in-asp-net-applications/ for some common methods of troubleshooting.

Upvotes: 0

shishir
shishir

Reputation: 851

You need to create a Method to check session and call that method on each asp page you are using in your application.

Sub CheckSession()
    If Session("LoginID") = "" Then
        Response.Redirect "../Login.asp"
    End If
End Sub

Then call the CheckSession() method in every asp page,

Call CheckSession()

On top of the asp page which you need to bind with the session you also need to include the asp file where you have declared the CheckSession() Method.

As I have created a SharedPost.asp page and created all the methods in there and included it to my other asp page.

<!--#include file="../Shared/SharedPost.asp" -->

Upvotes: 0

Related Questions