Frage

We have a ASP.NET 2.0 website with some old classic asp pages on it. There is a login.asp page and home.aspx page. Login.asp page is redirected to the home.aspx for authenticated and authorized users.

We want to count the number of users visiting the site. If the user reaches some specified value, we are displaying some popup with some information. We are storing the Application variables on the global.asax file. Please fine the following code snipped for the global.asax

Protected Overloads Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    Application("Count") = 0
End Sub

Protected Overloads Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)        
    Application("Count") = CInt(Application("Count"))+ 1        
End Sub

I am accessing the Application("Count") on the PageLoad method of Home.aspx.

When I open the browser with url http://localhost/login.asp and successfully login, the count never increases. If I go to http://localhost/home.aspx, the count increases. It looks like when login.asp redirects to the home.aspx, it doesn't call the session_start on the global.asax.

I am not very familiar with Classic asp. The end users always come from the login.asp.

What's the best way to access the correct incremented Application variable from global.asax file?

War es hilfreich?

Lösung

Classic ASP pages are not processed by the ASP.Net engine. This means that it is correct that the Global.asax events are never fired for .asp urls.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top