Re: global.asa question (asp pages)

From: Kevin Spencer (kevin_at_takempis.com)
Date: 02/25/04


Date: Wed, 25 Feb 2004 09:28:30 -0500

Hi Doris,

You're close, and I don't blame you for misunderstanding a bit under the
circumstances. In an ASP application, the global.asa file must reside in the
APPLICATION ROOT (not the WEB (domain) ROOT). This might seem like a trivial
difference, but it is not. A web site is different than a Web Domain, and a
Web Domain can have multiple web sites and web applications
inside/underneath it. Each Subweb can be configured as an Application, in
which case you can actually store a global.asa file in that directory and it
will function as the global.asa file for that ASP application. So, you can
have multiple subwebs (web sites) under your root domain, each with its own
Application, and its own global.asa file.

-- 
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Doris Edwards" <microsol@rikki-tikki-tavi.com> wrote in message
news:403c6bd9$2_1@news.bluewin.ch...
> Hello,
> I have several .mdb Access databases stored with on a web server (not my
> own, but with a very professional hosting service). I have developped .asp
> forms with FrontPage
>
> The individual web applications are placed in /webroot/(name of web) of
the
> hosting server's web server.
>
> The databases belonging to the individual applications are stored in
> /webroot/data of the hosting server's web server. I have established a DSN
> pointer in ODBC data sources to point to the databases. All this works
fine
> when there is one application and one database.
>
> The global.asa is generated by FrontPage is placed into /webroot, and off
we
> go.
>
> The problem comes when there are several databases. My question :
>
> FrontPage generates a global.asa for each application (I know that there
can
> be only one per application). As global.asa needs to be at the webroot,
how
> does this then work ? I have modified global.asa to include the pointers
to
> DSN's. I am listing the modified global.asa file than here below. But
maybe
> this is not the right approach. I get errors when opening the forms
>
> Would be most grateful for your help. Thanks. Doris
> ---------------------------------------
> Contents of GLOBAL.ASA
>
> <SCRIPT LANGUAGE=VBScript RUNAT=Server>
> Sub Application_OnStart
>  '==FrontPage Generated - startspan==
>  Dim FrontPage_UrlVars(4)
>  '--Project Data Connection
>   Application("Catalogue_ConnectionString") = "DRIVER={Microsoft Access
> Driver (*.mdb)};DBQ=URL=data/Catalogue.mdb"
>   FrontPage_UrlVars(0) = "Catalogue_ConnectionString"
>   Application("Catalogue_ConnectionTimeout") = 15
>   Application("Catalogue_CommandTimeout") = 30
>   Application("Catalogue_CursorLocation") = 3
>   Application("Catalogue_RuntimeUserName") = "rikkit"
>   Application("Catalogue_RuntimePassword") = "ehql+cfz"
>  '--Project Data Connection
>   Application("Losinger2_ConnectionString") = "DRIVER={Microsoft Access
> Driver (*.mdb)};DBQ=URL=data/Losinger.mdb"
>   FrontPage_UrlVars(1) = "Losinger2_ConnectionString"
>   Application("Losinger2_ConnectionTimeout") = 15
>   Application("Losinger2_CommandTimeout") = 30
>   Application("Losinger2_CursorLocation") = 3
>   Application("Losinger2_RuntimeUserName") = "rikkit"
>   Application("Losinger2_RuntimePassword") = "ehql+cfz"
>  '--Project Data Connection
>   Application("GHS2004_ConnectionString") = "DRIVER={Microsoft Access
Driver
> (*.mdb)};DBQ=URL=data/GHS2004.mdb"
>   FrontPage_UrlVars(2) = "GHS2004_ConnectionString"
>   Application("GHS2004_ConnectionTimeout") = 15
>   Application("GHS2004_CommandTimeout") = 30
>   Application("GHS2004_CursorLocation") = 3
>   Application("GHS2004_RuntimeUserName") = "rikkit"
>   Application("GHS2004_RuntimePassword") = "ehql+cfz"
>  '--Project Data Connection
>   Application("CatalogueVessy_ConnectionString") = "DRIVER={Microsoft
Access
> Driver (*.mdb)};DBQ=URL=data/CatalogueVessy.mdb"
>   FrontPage_UrlVars(0) = "CatalogueVessy_ConnectionString"
>   Application("CatalogueVessy_ConnectionTimeout") = 15
>   Application("CatalogueVessy_CommandTimeout") = 30
>   Application("CatalogueVessy_CursorLocation") = 3
>   Application("CatalogueVessy_RuntimeUserName") = "rikkit"
>   Application("CatalogueVessy_RuntimePassword") = "ehql+cfz"
>  '--
>  Application("FrontPage_UrlVars") = FrontPage_UrlVars
>  '==FrontPage Generated - endspan==
> End Sub
> Sub Session_OnStart
>  FrontPage_StartSession '==FrontPage Generated==
> End Sub
> Sub FrontPage_StartSession
>  On Error Resume Next
>  if Len(Application("FrontPage_VRoot")) > 0 then Exit Sub
>  ' discover the VRoot for the current page;
>  ' walk back up VPath until we find global.asa
>  Vroot = Request.ServerVariables("PATH_INFO")
>  strG1 = "global.asa"
>  strG2 = "Global.asa"
>  iCount = 0
>  do while Len(Vroot) > 1
>   idx = InStrRev(Vroot, "/")
>   if idx > 0 then
>    Vroot = Left(Vroot,idx)
>   else
>    ' error; assume root web
>    Vroot = "/"
>   end if
>   if FrontPage_FileExists(Server.MapPath(Vroot & strG1)) then exit do
>   if FrontPage_FileExists(Server.MapPath(Vroot & strG2)) then exit do
>   if Right(Vroot,1) = "/" then Vroot = Left(Vroot,Len(Vroot)-1)
>   iCount = iCount + 1
>   if iCount > 100 then
>    ' error; assume root web
>    Vroot = "/"
>    exit do
>   end if
>  loop
>  ' map all URL= attributes in _ConnectionString variables
>  Application.Lock
>  if Len(Application("FrontPage_VRoot")) = 0 then
>   Application("FrontPage_VRoot") = Vroot
>   UrlVarArray = Application("FrontPage_UrlVars")
>   for i = 0 to UBound(UrlVarArray)
>    if Len(UrlVarArray(i)) > 0 then FrontPage_MapUrl(UrlVarArray(i))
>   next
>  end if
>  Application.Unlock
> End Sub
> Sub FrontPage_MapUrl(AppVarName)
>  ' convert URL attribute in conn string to absolute file location
>  strVal = Application(AppVarName)
>  strKey = "URL="
>  idxStart = InStr(strVal, strKey)
>  If idxStart = 0 Then Exit Sub
>  strBefore = Left(strVal, idxStart - 1)
>  idxStart = idxStart + Len(strKey)
>  idxEnd = InStr(idxStart, strVal, ";")
>  If idxEnd = 0 Then
>   strAfter = ""
>   strURL = Mid(strVal, idxStart)
>  Else
>   strAfter = ";" & Mid(strVal, idxEnd + 1)
>   strURL = Mid(strVal, idxStart, idxEnd - idxStart)
>  End If
>  strOut = strBefore & Server.MapPath(Application("FrontPage_VRoot") &
> strURL) & strAfter
>  Application(AppVarName) = strOut
> End Sub
> Function FrontPage_FileExists(fspath)
>  On Error Resume Next
>  FrontPage_FileExists = False
>  set fs = CreateObject("Scripting.FileSystemObject")
>  Err.Clear
>  set istream = fs.OpenTextFile(fspath)
>  if Err.Number = 0 then
>   FrontPage_FileExists = True
>   istream.Close
>  end if
>  set istream = Nothing
>  set fs = Nothing
> End Function
> </SCRIPT>
>
>
>
>
>


Relevant Pages

  • Re: ADO CursorType Problem
    ... this case recordset should inherit settings for the cursor type from this ... > Sub Application_OnStart ... > ' walk back up VPath until we match VRoot ... > If idxStart = 0 Then Exit Sub ...
    (microsoft.public.data.ado)
  • Re: ADO CursorType Problem
    ... this case recordset should inherit settings for the cursor type from this ... > Sub Application_OnStart ... > ' walk back up VPath until we match VRoot ... > If idxStart = 0 Then Exit Sub ...
    (microsoft.public.data.oledb)
  • Re: ADO CursorType Problem
    ... this case recordset should inherit settings for the cursor type from this ... > Sub Application_OnStart ... > ' walk back up VPath until we match VRoot ... > If idxStart = 0 Then Exit Sub ...
    (microsoft.public.frontpage)
  • Re: More than One
    ... affect the sub applications. ... In addition, for Master page, we can put different Master pages in ... referece Master pages in root application directory, ... Microsoft Online Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Secure Multiple Applications in one Domain
    ... root applicaiton 's root folder in IIS. ... Now you want the sub application's file also be ... use the same login page in the root web application. ... Regarding on the repeatly be redirect to login page. ...
    (microsoft.public.dotnet.framework.aspnet.security)