Hi Gang,
Let me start by saying I'm using Visual Web Developer 2005 and ASP.net
2.0. Is there something I have to do to get my Global.asax fire when
my application loads. If I set a breakpoint nothing happens also I can
tell that it's not updating my database. I'm storing the users's
session ID in the database to prevent multiple logins. However, when
their session expires it's not clearning their record. Are there
prohibitive constraints on the functionality accessible from
Global.asax?
Thanks a bundle,
Christian Blackburn
-------------------------------------------------------------------------------------------------------------------------------------
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
'Creates the database's Connection object
Dim oConn As New System.Data.Odbc.OdbcConnection("DSN=" &
strDSN)
'Creates a Command object
Dim oCommand As New System.Data.Odbc.OdbcCommand
'Opens the connection
oConn.Open()
'Specifies the command to execute,
'we're clearing all the recorded session IDs
oCommand.CommandText = "UPDATE users " & vbCrLf & _
"SET session_id = '';"
MsgBox(oCommand.CommandText)
'Tells the command object to use the connection above
oCommand.Connection = oConn
'Executes the command
oCommand.ExecuteNonQuery()
'Closes the database connection
oConn.Close()
End Sub
------------------------------------------------------------------------------------------------------------------------------------- 7 2246
Hi Gang,
Well no-one responded and I wound up using some sample code off the
web. The structure of my file was wrong and so it wasn't being fired.
If you need a working copy too:
have a look at the following:
------------------------------------------------------------------------------------------------------------------------------
<%@ Import Namespace="System.Data.ODBC" %>
<script language="VB" runat="server">
Const strDSN = "motoadvisor_mysqlConn"
Sub Application_Start(Sender As Object, E As EventArgs)
Dim oConn As New OdbcConnection("DSN=" & strDSN)
Dim oCommand As New OdbcCommand
oConn.Open()
oCommand.Connection = oConn
oCommand.CommandText = "Update users " & _
"SET session_id = ''"
oCommand.ExecuteNonQuery()
End Sub
Sub Application_End(Sender As Object, E As EventArgs)
' Clean up application resources here
End Sub
Sub Session_Start(Sender As Object, E As EventArgs)
'Sets the default timeout period for a session to 20 minutes
Session.Timeout = 20
End Sub
Sub Session_End(Sender As Object, E As EventArgs)
Dim oConn As New OdbcConnection("DSN=" & strDSN)
Dim oCommand As New OdbcCommand
oConn.Open()
oCommand.Connection = oConn
oCommand.CommandText = "Update users " & _
"SET session_id = '' " & _
"WHERE session_id = '" &
Session.SessionID & "'"
oCommand.ExecuteNonQuery()
End Sub
Sub Application_Error(Sender As Object, E As EventArgs)
End Sub
</script>
------------------------------------------------------------------------------------------------------------------------------
Thanks,
Christian Blackburn
Please review this article which details the Application lifecycle : http://msdn2.microsoft.com/en-us/library/ms178473.aspx
Application_Start fires *once* in the application's life.
You cannot use it to capture data about individual users.
Try putting your code in the Session_Start event handler in global.asax.
btw, you'll need to modify your code so that
1. it actually inserts the session id into your database
2. It doesn't use MsgBox ( Msgbox runs client-side, not server-side )
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Christian Blackburn" <ch*****************@Yahoo.com> wrote in message
news:11*********************@y41g2000cwy.googlegro ups.com... Hi Gang,
Let me start by saying I'm using Visual Web Developer 2005 and ASP.net 2.0. Is there something I have to do to get my Global.asax fire when my application loads. If I set a breakpoint nothing happens also I can tell that it's not updating my database. I'm storing the users's session ID in the database to prevent multiple logins. However, when their session expires it's not clearning their record. Are there prohibitive constraints on the functionality accessible from Global.asax?
Thanks a bundle, Christian Blackburn -------------------------------------------------------------------------------------------------------------------------------------
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
'Creates the database's Connection object Dim oConn As New System.Data.Odbc.OdbcConnection("DSN=" & strDSN)
'Creates a Command object Dim oCommand As New System.Data.Odbc.OdbcCommand
'Opens the connection oConn.Open()
'Specifies the command to execute, 'we're clearing all the recorded session IDs oCommand.CommandText = "UPDATE users " & vbCrLf & _ "SET session_id = '';"
MsgBox(oCommand.CommandText)
'Tells the command object to use the connection above oCommand.Connection = oConn
'Executes the command oCommand.ExecuteNonQuery()
'Closes the database connection oConn.Close()
End Sub
-------------------------------------------------------------------------------------------------------------------------------------
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ui**************@TK2MSFTNGP04.phx.gbl... 2. Msgbox runs client-side, not server-side
Having a bit of a senior moment, Juan...? :-)
re: 2. Msgbox runs client-side, not server-side Having a bit of a senior moment, Juan...? :-)
Not really.
They way he coded it, in Application_Start,
MsgBox would attempt to run on the server:
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
....snip...
MsgBox(oCommand.CommandText)
....snip...
That will throw an error. See : http://p2p.wrox.com/topic.asp?TOPIC_ID=9675
Am I missing something ?
For a nifty MsgBox server control for ASP.NET, see : http://www.codeproject.com/aspnet/Ni...pleControl.asp
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl... "Juan T. Llibre" <no***********@nowhere.com> wrote in message news:ui**************@TK2MSFTNGP04.phx.gbl...
2. Msgbox runs client-side, not server-side
Having a bit of a senior moment, Juan...? :-)
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uL**************@TK2MSFTNGP02.phx.gbl... 2. Msgbox runs client-side, not server-side Having a bit of a senior moment, Juan...? :-)
Not really.
They way he coded it, in Application_Start, MsgBox would attempt to run on the server:
Indeed - that's why I was puzzled that you said Msgbox runs client-side, not
server-side...
re: They way he coded it, in Application_Start, MsgBox would attempt to run on the server: that's why I was puzzled that you said Msgbox runs client-side, not server-side...
It *does* run client-side. In fact, it can *only* run on the client.
Juan wrote : you'll need to modify your code so that
....snip... it doesn't use MsgBox ( Msgbox runs client-side, not server-side )
IOW, he was coding it thinking that MsgBox would run client-side,
if he coded it into Application_Start. It won't run from Application_Start.
They way he coded it, MsgBox would attempt to run on the server, which it can't do.
Maybe it's just a semantics thing... ;-)
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:OK**************@TK2MSFTNGP03.phx.gbl... "Juan T. Llibre" <no***********@nowhere.com> wrote in message news:uL**************@TK2MSFTNGP02.phx.gbl...
2. Msgbox runs client-side, not server-side Having a bit of a senior moment, Juan...? :-)
Not really.
They way he coded it, in Application_Start, MsgBox would attempt to run on the server:
Indeed - that's why I was puzzled that you said Msgbox runs client-side, not server-side...
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Ol**************@TK2MSFTNGP02.phx.gbl... Maybe it's just a semantics thing... ;-)
Yeah, sorry - I was pretty sure I knew what you meant... :-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Halcyon Woodward |
last post by:
I have an odd problem...
We have a small development team (three coders) working on the same project
(a C# web application). Each coder has a unique 'sandbox' site on a shared
Windows 2003...
|
by: Ober |
last post by:
I'm having trouble with my security model, Application_Start, and accessing
my database.
My ASP.NET app is only going to be running in an intranet environment (not
on the public Internet). ...
|
by: csn |
last post by:
Is it possible to have a Response.Redirect in Global.asax in the
Application_Start and Session_Start events?
We have code in both events, with try-catch blocks, and if an exception is
caught, we...
|
by: Saar Carmi |
last post by:
Hi
How can I get the application's virtual directory from the
Application_Start method in Global.asax ?
Keep in mind there is no request/response object available yet in this
stage.
Thanks...
|
by: NoNickname |
last post by:
Hi,
I need to get a string from a COM component at application start. (It's a
Long Story and I cannot change this fact.) In ASP.NET 1.1, I simply called
this COM component in Global.asax.cs...
|
by: Joe Befumo |
last post by:
I just created the default personal site project in Visual Studio 2005, and it worked perfectly -- very nice.
Next, I'd like to import some stat-capture code that I have working in a Visual Studio...
|
by: Harlan Messinger |
last post by:
How do the Application methods like
protected void Application_Start
get called? They aren't base class overrides and they aren't
implementing interface methods. What mechanism does the system...
|
by: gamesforums |
last post by:
Hi!
I have some code within the Application_Start event in Global.asax
that runs a sqlscript against my sql server to check the databas
version. My problem is that sometimes the...
|
by: Aamir Mahmood |
last post by:
Hi
I have a problem that just appeared to my application.
I have some initialization code in Application_Start function in global.asax
but it is not being called when the application pool is...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |