global.asa and global.asax file?

Posted on 2006-04-12
Last Modified: 2012-06-27
I have two files in visual source safe one with global.asa
and the other global.asax,global.asax.res, global.asax.vb.

The global.asa contains the following:


' C.C. Financial Evaluation Model global.asa
' Copyright 2001 Zurich North America
' Corporate Customer

'You can add special event handlers in this file that will get run automatically when
'special Active Server Pages events occur. To create these handlers, just create a
'subroutine with a name from the list below that corresponds to the event you want to
'use. For example, to create an event handler for Session_OnStart, you would put the
'following code into this file (without the comments):

'Sub Session_OnStart
'**Put your code here
'End Sub

'EventName Description
'Session_OnStart Runs the first time a user runs any page in your application
'Session_OnEnd Runs when a user's session times out or quits your application
'Application_OnStart Runs once when the first page of your application is run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down

Dim aDBParams()
Dim aEntParams()
Dim sRegSetting
Dim objRegRead
Dim nParamCnt
Dim nEntCnt
Dim nLoopCnt

Function ParseString (SubStrs, argSrcStr, Delimiter )

      ' Dimension variables:
      ReDim SubStrs(0)
      Dim CurPos
      Dim NextPos
      Dim DelLen
      Dim nCount
      Dim TStr
      Dim SrcStr

      ' Add delimiters to start and end of string to make loop simpler:
      SrcStr = Delimiter & SrcStr & Delimiter
      ' Calculate the delimiter length only once:
      DelLen = Len(Delimiter)
      ' Initialize the count and position:
      nCount = 0
      CurPos = 1
      NextPos = InStr(CurPos + DelLen, SrcStr, Delimiter)

      ' Loop searching for delimiters:
      Do Until NextPos = 0
         ' Extract a sub-string:
         TStr = Mid(SrcStr, CurPos + DelLen, NextPos - CurPos - DelLen)
         ' Increment the sub string counter:
         nCount = nCount + 1
         ' Add room for the new sub-string in the array:
         ReDim Preserve SubStrs(nCount)
         ' Put the sub-string in the array:
         SubStrs(nCount) = Trim(TStr)
         ' Position to the last found delimiter:
         CurPos = NextPos
         ' Find the next delimiter:
         NextPos = InStr(CurPos + DelLen, SrcStr, Delimiter)

      ' Return the number of sub-strings found:
      ParseString = nCount

   End Function

' Use Application variables since they do not change from session to session
Sub application_OnStart()
Dim sDBParams()
Dim sEntParms()
Dim sRegSetting
Dim objRegRd
Dim nParmCnt
Dim nEntCnt
Dim nLoopCnt
    ' =========> ChannelZ Home page <=================
    'Development Server
         application("ChannelZSvr") = ""
    'Staging Server
            'application("ChannelZSvr") = ""
        'Prod Server
        'application("ChannelZSvr") = ""

    ' =========> IIS Home page <=================
    'Dev Server
        application("IISHomeURL") = ""
    'Staging Server
            '*application("IISHomeURL") = ""
        'Prod Server
        '*application("IISHomeURL") = ""

    ' =========> Enterprise Risk Home page <=================
    'Dev Server
          application("Ent_Risk_Home") = ""
     '' application("Ent_Risk_Home") = "" Cutover

    'Staging Server
        'application("Ent_Risk_Home") = ""
    'Prod Server
        'application("Ent_Risk_Home") = ""

    ' =========> Enterprise Risk WEB Paths used by Financial Model <=================
    '--> Applications Home Page
    Application("applications_home_page_path") = "corporate_customer/applications"

    '--> Financial Model directory structure
    Application("financial_model_path") = "corporate_customer/applications/financial_evaluation_model"


    ' =========> Enterprise Risk Application Variables used by Financial Evaluation Model <=================
    ' =========> These are used by the reporting section <=================
    ' the following applications variables are initialized from the registry of the server
    'DataBase Server Name = Application("Data Source")
    'DataBase Name = Application("Initial Catalog")
    'userid for reporting = Application("User Id")
    'Password for reporting userid = Application("Password")
    ' see file regcom.reg for setup of registry entry

    set objRegRead = server.CreateObject("ZUSER_FinMRdRegKy.clReadReg")
    sRegSetting = objRegRead.ReadReg("ZUSER_FinM","Database","Connect")

    nParamCnt = ParseString(aDBParams,sRegSetting,";")
    for nLoopCnt = 1 to nParamCnt -1 step 1
            nEntCnt = ParseString(aEntParams,aDBParams(nLoopCnt),"=")
            if nEntCnt = 2 then
                Application(aEntParams(1))= aEntParams(2)
            end if

    sRegSetting = objRegRead.ReadReg("ZUSER_FinM","Database","ReportsDSN")
    set pobjRegRead = Nothing
    nParamCnt = ParseString(aDBParams,sRegSetting,";")
    for nLoopCnt = 1 to nParamCnt -1 step 1
            nEntCnt = ParseString(aEntParams,aDBParams(nLoopCnt),"=")
            if nEntCnt = 2 then
                Application(aEntParams(1))= aEntParams(2)
            end if

   ' =========> Domino Web servers <=================
    'Dev Server
             application("DominoHomeURL") = ""
    'Staging Server
        'application("DominoHomeURL") = ""
    'Production Server
        'application("DominoHomeURL") = ""
End Sub


and this is the global.asax.vb:


Imports System.Web
Imports System.Web.SessionState
Imports clsRegistryRead
Public Class Global
    Inherits System.Web.HttpApplication

#Region " Component Designer Generated Code "

    Public Sub New()

        'This call is required by the Component Designer.

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Required by the Component Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Component Designer
    'It can be modified using the Component Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
    End Sub

#End Region

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application is started
        Dim rReg As New clsRegistryRead.FinMod_RegistryReader()
        Application("ConnectString") = rReg.GetCurrUserRegistryValue(".Default\Software\VB and VBA Program Settings\ZUSER_FinM\Database", "Connect")
    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the session is started
    End Sub

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires at the beginning of each request
    End Sub

    Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires upon attempting to authenticate the use
    End Sub

    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when an error occurs
    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the session ends
    End Sub

    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application ends
    End Sub

End Class

Which one is being run when the default.asp page is being loaded?

Question by:mathieu_cupryk
    LVL 6

    Expert Comment

    Global.asax is the .NET equivalent of the Classic ASP Global.asa file.
    Have you converted the app from an ASP3.0 file?
    If you are using ASP and ASP.NET files, the ASP.NET pages, the ASP.NET pages call the global.asax file.

    For more information on the changes, check out:

    hope this helps,

    Author Comment

    There are aspx pages and asp pages so what happens in this case?
    LVL 6

    Accepted Solution

    Sorry, fell short of explaining that didn't I?!
    The aspx pages reference the Global.asax whereas the asp pages reference the global.asa file.
    The reason is that although ASP/ ASPX pages can be used side-by-side, application and session state are not shared between them.


    Author Comment


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now