Access Virtual Directory with Application_OnStart

M

Mark Hoagland

I've got a scenario with a web application where I must
access the virtual directory being accessed from within
the Application_OnStart event handler. Specifically, I
have a series of IIS virtual directories which all point
to the same set of ASP pages. However, since each virtual
directory is a separate 'application', each has its own
set data which must be cached. To detect which data must
be cached for each virtual directory, I need to detect the
name of the virtual directoy being invoked from within the
Application_OnStart event.

The problem is that the Request.ServerVariables collection
is not avaiable within the Application_OnStart event
handler. Is there a workaround for this?

Thanks,
Mark
 
C

CJM

This sounds liek a complicated design... can you give some background? There
may be an alternative design that avoids this problem...

CJM
 
M

Mark Schupp

put your init code into session_onstart
use an app var as a flag to skip the init code if a particular virtual dir
has already been initialized.
 
M

Mark Hoagland

Session_OnStart is not a viable alternative because we
have session state disabled on all virtual directories.
We've found that enabling session state decreases the
scalability of our application by 25-40%, so we always
disable session state.

As for the overall design of the application, it is a
massive ASP based application with about 2500 pages for
managing customer interactions. The reason that we must
have multiple virtual directories pointing to the same
code base is that I work for a hosting company, so we have
multiple customers on the same application. The trick is
that the application is based upon a packaged, enterprise
software application so we must upgrade our modified
version of the product periodically and to minimize the
overall maintenance and upgrade effort we keep all of our
customers on a single code base. We initially started out
with each virtual directory pointing to a separate copy of
the code, but found that propagating changes to the
servers would take 10+ hours. Plus, the overall effort to
manage that many 'sets' of code was going to force us to
hire at least one additional programmer.
 
M

Mark Schupp

sounds like you are between the ol' rock and hard place.

Do users always enter the application through the same ASP page (default.asp
for instance)?
If so, add the initialization code to that page. Check for a specific app
var to avoid re-initialization.

Another option would be to set up a manual initialization page that you
could call directly after the web-server is re-started to load the
application vars. Then call it via each valid path (this would be
problematic if your server does unattended restarts).

Yet another option would be to add an include file to each page that a user
might enter the app with. You might be able to do something like this with a
global search/replace utility.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top