Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2003, 03:40 PM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to call application variable in global.asa

Hi

Please help

I don't understand why I could not get the value which I defined in global.asa file.

here is my global.asa file

<OBJECT RUNAT=Server SCOPE=Session ID=MyInfo PROGID="MSWC.MyInfo">
</OBJECT>

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
Application("BldgRootFolderPath")="http://"&<% =Request.ServerVariables(SERVER_NAME) %>&"/bldg/"
End Sub
Sub Application_OnEnd
Application("BldgRootFolderPath")=""

End Sub

And in my .asp file I called different ways, but I could not get the value

<% Application("BldgRootFolderPath") %>

  <% Application(BldgRootFolderPath) %>
  <% =Application(BldgRootFolderPath) %>


  <% =BldgRootFolderPath %>



 
Old July 25th, 2003, 04:42 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

The problem may be caused by the fact that the Application has a scope for the entire application, while the Request is related to an individual user / request.

When the app starts, I guess there is no such thing as Request.ServerVariables......

HtH

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old July 25th, 2003, 04:54 PM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

when I try to change my application value to 1 I still could not be able to retrieve the value



here is my global.asa file

<OBJECT RUNAT=Server SCOPE=Session ID=MyInfo PROGID="MSWC.MyInfo">
</OBJECT>

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
  Application("BldgRootFolderPath")=1
End Sub


And in my .asp file I called different ways, but I could not get the value

<% Application("BldgRootFolderPath") %>

  <% Application(BldgRootFolderPath) %>
  <% =Application(BldgRootFolderPath) %>


  <% =BldgRootFolderPath %>

 
Old July 25th, 2003, 05:09 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Right, I see.

Here's what's wrong with the stuff you tried:

  <% Application("BldgRootFolderPath") %>

This is the correct way to retrieve the value, but you are not outputting it.

  <% =Application(BldgRootFolderPath) %>

This is the correct way to output it, but you are not really retrieving it. BldgRootFolderPath is a local variable, and not the name of the App variable.

Mix the two:

  <% =Application("BldgRootFolderPath") %>

and it should work.

Tip of the day: Add this to the top of every ASP page you create:

<% Option Explicit %>

This forces you to declare your variables, so you could have caught the problem with BldgRootFolderPath.

HtH

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old July 28th, 2003, 11:28 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thanks it works!!

:)





Similar Threads
Thread Thread Starter Forum Replies Last Post
global.asa vin_0x1 Classic ASP Components 2 July 24th, 2006 01:13 AM
Global.asa gmoney060 Classic ASP Basics 3 September 25th, 2004 09:11 AM
how to call Application Variable from global .asax ranakdinesh ASP.NET 1.0 and 1.1 Basics 2 August 6th, 2004 06:01 AM
Global.asa madsmad ASP.NET 1.0 and 1.1 Basics 1 August 17th, 2003 07:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.