Application Variables

Results 1 to 3 of 3

Thread: Application Variables

  1. #1
    Join Date
    Dec 1969
    Posts
    730

    Default Application Variables

    I cannot get global application variables to come through to ASP. I set up the global.asa file in the root directory with:<BR>-------------------------------------------<BR>&#060;SCRIPT LANGUAGE="VBScript" RUNAT="Server"><BR>Sub Application_OnStart<BR>Application("message") = "Welcome"<BR>End Sub<BR>&#060;/SCRIPT><BR>--------------------------------------------<BR><BR>I put the following into a separate ASP page in the same directory:<BR><BR>---------------------------------------------<BR>&#060;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><BR><BR>&#060;%@ Language=VBScript &#037;&#062; <BR>&#060;HTML><BR>&#060;HEAD><BR>&#060;TITLE>Glob al Variable test&#060;/TITLE><BR>&#060;/HEAD><BR>&#060;BODY><BR>&#060;%=Application("messa ge")&#037;&#062;<BR>&#060;/BODY><BR>&#060;/HTML><BR>------------------------------------------<BR><BR>The outcome is nothing. How is the application variable retrieved from the global.asa?

  2. #2
    Chris Willey Guest

    Default RE: Application Variables

    2 things:<BR><BR>1) You might want to use session variables rather than application variables, because the value of an application variable is set once the first time someone enters the application and doesn&#039t end until IIS is shut down. Session variables are set every time a session begins (in global.asa).<BR>2) Make sure that you&#039ve set up the directory where the global.asa file is as a virtual root in IIS. Then restart IIS. Otherwise global.asa&#039s don&#039t function.

  3. #3
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Application Variables

    Two things:<BR><BR>1.) Your #2 tip about the virtual directories, that is correct, your globabl.asa won&#039t fire unless it is in a virtual directory.<BR><BR>2.) Session variables are evil. There is a time and a place for Application variables (and, I guess, Session variables, but it&#039s an evil time and an evil place).<BR><BR>Have a great day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •