Avatar billede krc_ Nybegynder
27. december 2003 - 16:22 Der er 7 kommentarer og
1 løsning

2 global.asa

Hej !

Jeg har det problem at jeg har 2 forskellige scripts på min hjemmeside der begge bruger global.asa. Hver for sig virker de fint, men hvis jeg så smider koden for den ene ind i den anden så virker første script ikke mere. Men kan kan jo ikke have 2 global.asa vel ?

Sådan her ser den ene ud :

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
' Set our user count to 0 when we start the server
Application("ActiveUsers") = 0
End Sub
Sub Session_OnStart
' Change Session Timeout to 20 minutes (if you need to)
Session.Timeout = 5
' Set a Session Start Time
' This is only important to assure we start a session
Session("Start") = Now
' Increase the active visitors count when we start the session
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.UnLock
End Sub
Sub Session_OnEnd
' Decrease the active visitors count when the session ends.
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.UnLock
End Sub
</script>


og sådan her den anden :

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
    '==FrontPage Generated - startspan==
    Dim FrontPage_UrlVars(0)
    '--
    Application("FrontPage_UrlVars") = FrontPage_UrlVars
    '==FrontPage Generated - endspan==

'*******************************************************************************************************************   
' Make sure Data Source points to your RAMS Oracle Database
'*******************************************************************************************************************   
    Application("dbString") = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("Calendar.mdb") & ";"

'*******************************************************************************************************************   
' Database timeout values, and instance username and passwords (redundant)
'*******************************************************************************************************************   
    Application("dbTimeout") = 15
    Application("dbTimeout") = 30
    Application("dbCursorLocation") = 3
   
End Sub
Sub FrontPage_StartSession
    On Error Resume Next
    if Len(Application("FrontPage_VRoot")) > 0 then Exit Sub
   
    sFile = "global.asa"
    sRootPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
    if Left(sRootPath,1) = "/" then sSep = "/" else sSep = "\"
    if Right(sRootPath,1) <> sSep then sRootPath = sRootPath & sSep
    sRootPath = sRootPath & sFile
   
    ' discover the VRoot for the current page;
    ' walk back up VPath until we match VRoot
    Vroot = Request.ServerVariables("PATH_INFO")
    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 Server.MapPath(Vroot & sFile) = sRootPath 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

Sub Session_OnStart
    FrontPage_StartSession '==FrontPage Generated==

    UserAgent = Request.ServerVariables("HTTP_USER_AGENT")
    If InStr(1,UserAgent,"MSIE 5.") < 0 OR InStr(1,UserAgent,"MSIE 6.") < 0 then
        Response.Write UserAgent & "<hr>"
        Response.Write "Browser Not Supported...."
        Session.Abandon
        Response.End
    End If
End Sub

</SCRIPT>



Er der en der kan skrive den sammen i en global.asa så de virker eller hur fixer jeg den ?
Avatar billede erikjacobsen Ekspert
27. december 2003 - 16:24 #1
Du skal bare putte ting fra samme "sub" i samme "sub" - hvis du forstår ;)
Avatar billede krc_ Nybegynder
27. december 2003 - 16:29 #2
øhhh ik helt..har aldrig set en global.asa før :D
Avatar billede erikjacobsen Ekspert
27. december 2003 - 16:33 #3
Sub Application_OnStart
  blip
end sub

fra den ene global.asa og

Sub Application_OnStart
  blåp
end sub

fra den anden, skal bare blive til

Sub Application_OnStart
  blip
  blåp
end sub

i den ene du skal have liggende
Avatar billede krc_ Nybegynder
27. december 2003 - 16:48 #4
hehe...okay...
Men der er ikke noget af det fra de 2 der konflikter eller sådan noget ?
Avatar billede erikjacobsen Ekspert
27. december 2003 - 16:52 #5
Hvis de bruger de samme navn, så jo - det har jeg ikke kigget efter
Avatar billede krc_ Nybegynder
27. december 2003 - 16:57 #6
smid et svar...det virker! Taak
Avatar billede erikjacobsen Ekspert
27. december 2003 - 17:03 #7
nej skidt med det - du lavede arbejdet
Avatar billede krc_ Nybegynder
27. december 2003 - 17:09 #8
okay...men taak for hjælpen alligevel.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester