473,624 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Loc k() 'Add 1 to active visitor count when new visitor
Application("co unter99") = Application("co unter99") + 1
Application.UnL ock()

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(B yVal sender As Object, ByVal e As EventArgs)
Application.Loc k() 'Sub 1 active visitor count when new visitor
Application("co unter99") = Application("co unter99") - 1
Application.UnL ock()
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 1875
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.UserC ount +=1
Response.Write( MyGlobals.UserC ount.ToString() )
End Sub

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

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

public shared UserCount as integer = 1

Sub Application_OnS tart()
' Application startup code goes here.
End Sub

Sub Session_OnStart ()
' Session startup code goes here.

Application.Loc k()
Application("So meGlobalCounter ") =
CType(Applicati on("SomeGlobalC ounter"),Intege r) + 1
Application.UnL ock()

End Sub

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

Sub Application_OnE nd()
' Application cleanup code goes here.
End Sub

</script>


"Goober" <go****@christi an.net> wrote in message
news:ub******** ********@tk2msf tngp13.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.Loc k() 'Add 1 to active visitor count when new visitor
Application("co unter99") = Application("co unter99") + 1
Application.UnL ock()

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(B yVal sender As Object, ByVal e As EventArgs)
Application.Loc k() 'Sub 1 active visitor count when new visitor
Application("co unter99") = Application("co unter99") - 1
Application.UnL ock()
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
1857
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 the whole application, is to pass the conversion wizard and see how it goes. But we want to keep those client VBA modifications working with the least
2
5384
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
1723
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 = application("variable"), and it will be shared by all user ... but I am not very sure about it, anyone know it ? Thanks, Tee
9
2447
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 at http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session, Application and Cache variables on the first page and then on the second page view them as the second page is refreshed every five seconds. Before 10 refreshes, the...
3
1829
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 answer. I'd appreciate and help. Thanks. What I'm doing is creating a treeview with the structure as follows (this is the expanded view): - Item Status - Item Status Details
2
1189
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 everything has passed it is true, but when it gets passed to the calc function it turns to false on the DimblnAnswer as Boolean = ValidateEntries() although the subprocedure is true. We bypassed the assignment and ran the code with just the...
47
2849
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 used and why ? Thanx
1
2638
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" Src="ctrls/Curve.ascx" %> This does not report any errors, but when I try to use it like <Oaklodge:Curve runat="server" /> I get the following error
2
1455
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 a simple query, BTW, so I'm using a DataReader, not a DataTable). The business object has no knowledge of the application, and hence of the Cache, which is where I would normally put this kind of thing (actually, I used to put this stuff in...
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8488
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.