473,394 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Application variable question (conversion from asp to dotnet)

I converted a website that was done in ASP to dotnet, and brought over a
number of items, some of which don't appear to work in the same way on
dotnet as they did on ASP.

One of them is an application variable.

I have this code in my global.asax in the Sub Session_Start:

Application.Lock() 'Add 1 to active visitor count when new visitor
Application("counter99") = Application("counter99") + 1
Application.UnLock()

It's a counter that I increment each time a user logged in to my old ASP
site.

I have this in the Sub Session_OnEnd to decrement the same counter:

Sub Session_OnEnd(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock() 'Sub 1 active visitor count when new visitor
Application("counter99") = Application("counter99") - 1
Application.UnLock()
End Sub

I know that in ASP, you couldn't really rely on the session end to get a
"good" accurate count on users, but in ASP, it generally worked, and
gave you a reasonable estimate of how many users were hitting the site
at a time.

In dotnet, this counter registers a number exponentially higher than
what it did in ASP.

Is there a way I can implement a counter for current users of the
website that would be a tad more accurate than this?

Any help appreciated.

Thanks

BC
Nov 19 '05 #1
1 1863
The code below should help you..

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

---somepage.aspx -----

<html>

<script language="VB" runat="server">
Sub Page_Load(Src as object, E as EventArgs)
MyGlobals.UserCount +=1
Response.Write(MyGlobals.UserCount.ToString())
End Sub

</script>
<body style="font: 10pt verdana">
Timneys Test
<form runat="server">
</form>
</body>
</html>
---global.asax----------

<%@ Application Classname="MyGlobals" %>
<script language="VB" runat="server">

public shared UserCount as integer = 1

Sub Application_OnStart()
' Application startup code goes here.
End Sub

Sub Session_OnStart()
' Session startup code goes here.

Application.Lock()
Application("SomeGlobalCounter") =
CType(Application("SomeGlobalCounter"),Integer) + 1
Application.UnLock()

End Sub

Sub Session_OnEnd()
' Session cleanup code goes here.
End Sub

Sub Application_OnEnd()
' Application cleanup code goes here.
End Sub

</script>


"Goober" <go****@christian.net> wrote in message
news:ub****************@tk2msftngp13.phx.gbl...
I converted a website that was done in ASP to dotnet, and brought over a
number of items, some of which don't appear to work in the same way on
dotnet as they did on ASP.

One of them is an application variable.

I have this code in my global.asax in the Sub Session_Start:

Application.Lock() 'Add 1 to active visitor count when new visitor
Application("counter99") = Application("counter99") + 1
Application.UnLock()

It's a counter that I increment each time a user logged in to my old ASP
site.

I have this in the Sub Session_OnEnd to decrement the same counter:

Sub Session_OnEnd(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock() 'Sub 1 active visitor count when new visitor
Application("counter99") = Application("counter99") - 1
Application.UnLock()
End Sub

I know that in ASP, you couldn't really rely on the session end to get a
"good" accurate count on users, but in ASP, it generally worked, and
gave you a reasonable estimate of how many users were hitting the site
at a time.

In dotnet, this counter registers a number exponentially higher than
what it did in ASP.

Is there a way I can implement a counter for current users of the
website that would be a tad more accurate than this?

Any help appreciated.

Thanks

BC

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Igor Mendizabal | last post by:
Hello We have a VB6 application that integrates an VBA IDE from which the final user can make modifications. We want to pass the application to VB.NET, and the first step, before rethinking...
2
by: babylon | last post by:
I have an enum public enum MyEnum : int { X, Y } I have to do int a = (int) MyEnum.X; can i overload the operator or other means to do something like
2
by: THY | last post by:
Hi, I am having some problem, I declare few variable in a public module and use them in the web application. But after that I found that the variable declared in public variable =...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
3
by: markaelkins | last post by:
Hi. I am trying to enter a variable in the treenodesrc of a treenode. I am basically trying to send an ID variable into sql to return different records. I've searched everywhere and cannot find the...
2
by: Tracer | last post by:
I have a variable named blnAnswer that is a flag in a subprocedure called ValidateEntries() set to true and tripped to false if something fails. When the variable comes out of the subprocedure and...
47
by: rawCoder | last post by:
Hi, Just wanted to know if there is any speed difference between VB conversion Keywords like CInt, Clng, CStr, CDbl, CBool etc. ..NETs Convert.To<...> methods. And which is better to be...
1
by: Michael Tissington | last post by:
I'm trying to convert a project from VS2003 to VS2005 After conversion all of my TagPrefix are not recognized in the body. <%@ Register TagPrefix="Oaklodge" TagName="Curve"...
2
by: Mark Olbert | last post by:
I want to bind a series of ObjectDataSource instances to an application-wide business object which caches the results of a database query. I'm confused about where/how to cache the results (it's...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.