Solved

Classic ASP application variables sporting empty strings

Posted on 2006-11-17
5
763 Views
Last Modified: 2010-08-05
My classic ASP applications rely on an application variable, application("Mode"), to know whether to exhibit test-environment or production-environment behavior.

At application_onstart, application("Mode") gets set to "dev" or "prod," depending on which site the user is accessing (I'm the only one accessing the "dev" site; all other users will access the prod version).

I'm the only developer of the applications and am developing on our development server, so if I understand application variables correctly, when I've been out past session timeout (10 minutes) and then access the dev site again, we can assume everything's re-initialized in dev.

Yesterday evening, one of our servers--not dev--got an upgrade from .NET 1.1 to 2.0.

First run this morning, both my classic ASPs on dev misbehaved, displaying no value for application("Mode").  

In case there was any connection I didn't know about between the dev server and the upgraded server, I talked with the upgrader, and he reemphasized the upgrade should not have affected them.  However, both applications had run fine yesterday.

Any input appreciated.  How did my dev apps fail to initialize their application-variable values?



My global, for one program:
------------------------------------------------------------------------------------------------------
<SCRIPT Runat="Server" Language="VBScript">
      sub application_on_start()
            session.timeout = 10            'sessions timeout after specified minutes.
            application("Log")                   = "true"
            application("Mode")                  = "dev"
      end sub
      sub session_onStart()
            session("lvl")                        = ""
            session("ApplicationID")            = ""
      end sub
</SCRIPT>




usage within program:
------------------------------------------------------------------------------------------------------

                  Select Case application("Mode")
                        Case "dev"
                                                          ...
                        Case "prod"
                                                          ...
                        Case else
                                                                               'here's the code executed because application("Mode") is empty
                              Response.Redirect("AccessDenied.aspx")  
                  End Select
0
Comment
Question by:CAWhite
  • 2
5 Comments
 
LVL 6

Expert Comment

by:davbouchard
ID: 17967136
There is actually a different. In ASP 2.0, the global file is moved to a script file. I am unsure as to why both your applications did this if he hasn't touched the dev server...

This site here explains how to fix it the global file : http://rossnelson.blogspot.com/2005/11/fixing-globalasax-in-aspnet-20.html :
"To add a global.asax, (or web.config for that matter), simply right click the web site or web server project in your solution explorer, select Add New Item from the context menu and then choose Global Application Class (or Web Configuration File for a web.config)."

I hope that helps.
0
 

Author Comment

by:CAWhite
ID: 17967274
Thanks for the info.  Alas, this application I've inherited is destined to remain a classic ASP for now ( despite the reference to an aspx I didn't even find in the folder) , and supposedly this server has not had a change.  I'm going to keep trying to figure out what happened to the app-variables.
0
 

Author Comment

by:CAWhite
ID: 17979178
OK, now the word is that the dev server did get updated--sounds like the upgrader hadn't anticipated that.  Since my two old applications were the only ones affected (global.asas not in wide use here, I guess), I moved my code to the applications' start pages.  Made my boss happy.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18025185
PAQd, 250 points refunded.

DarthMod
CS Moderator
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 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

21 Experts available now in Live!

Get 1:1 Help Now