470,591 Members | 2,170 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

Session variables - scope

Greetings one and all.

Server: Win2k(server)/IIS-5

There are many web sites on the server - each has a virtual directory
pointer to a common directory containing frequently used routines.

Scripts run from the virtual directory appear to have no access to session
(or application) variables. Is this expected behaviour? Or have I yet to
track down a bug?

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #1
8 3534
Application and session variables are unique to each application
defininition in IIS. When you create a virtual directory in IIS, a new
application is created for that directory by default. You can remove it,
and then it will be in the parent application.

Ray at work

"William Tasso" <ne****@tbdata.com> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
Greetings one and all.

Server: Win2k(server)/IIS-5

There are many web sites on the server - each has a virtual directory
pointer to a common directory containing frequently used routines.

Scripts run from the virtual directory appear to have no access to session
(or application) variables. Is this expected behaviour? Or have I yet to
track down a bug?

--
William Tasso - http://WilliamTasso.com

Jul 19 '05 #2
Ray at <%=sLocation%> wrote:
Application and session variables are unique to each application
defininition in IIS. When you create a virtual directory in IIS, a
new application is created for that directory by default. You can
remove it, and then it will be in the parent application.

Thanks for the info.

If it's not straying too far OT, are there any hints at how one might
achieve such a thing and whether there are any gotchas lying in wait for the
unwary.

or

perhaps an alternative method of providing reusable script modules to many
individual web sites on the same server.
--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #3
You can include the files with functions in them and then call the
functions:

incStringConcat.asp
====
<%
function StringConcat(Sting1, String2)
StringConcat = String1 & String2
end function
%>
====
default.asp
====
<!-- #INCLUDE FILE="incStringConcat.asp" -->
Concat "Hello" and " World!"<br>
<%
response.write(StringConcat("Hello"," World!"))
%>
====

Obviously a very simple example, but in that way you can pass variables to
your functions and share the functions.
"William Tasso" <ne****@tbdata.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Ray at <%=sLocation%> wrote:
Application and session variables are unique to each application
defininition in IIS. When you create a virtual directory in IIS, a
new application is created for that directory by default. You can
remove it, and then it will be in the parent application.
Thanks for the info.

If it's not straying too far OT, are there any hints at how one might
achieve such a thing and whether there are any gotchas lying in wait for

the unwary.

or

perhaps an alternative method of providing reusable script modules to many
individual web sites on the same server.
--
William Tasso - http://WilliamTasso.com

Jul 19 '05 #4
dlbjr wrote:

Many thanks to you both for your input.
William I do this with virtual includes.
ok - that's where I'm at.
I have many asp files with server side scripts.
The code is mainly VBScript Classes I use as Objects in any other
code. I include them in any web app with a virtual include in the asp.
Yep - that's what I'm doing. I have public properties and functions, some
of which call private functions. I'm in the process of building
encapsulated components for other developers to include in their sites and
was trying to abstract them even further so that just using the virtual
include world run trivial code, but I got a bit stuck with the
session/application variables. Still can't think of a way to completely
automate and encapsulate without hard-coding or using the suggestion from
Ray.
I have attached my main include Object that all my asp pages extend
from.


Thank you for the insight - very generous of you.

--
William Tasso
Jul 19 '05 #5
William,

The code is ran within the calling asp.
The Session and Application Variables for the App running are accessible in
the included code.

What exactly is the problem?
Are you trying to maintain central Application vars for all applications?

-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #6
dlbjr wrote:
William,

The code is ran within the calling asp.
yep
The Session and Application Variables for the App running are
accessible in the included code.
Not in this instance. The included code is located in the virtual directory
and appears (like Ray said) to behave like a new application.

What exactly is the problem?
Are you trying to maintain central Application vars for all
applications?


No - I guess that would be a different issue completely.

I'm building server side components for use by web deezinerzzz. This
particular component could produce all that's required of it with just a few
variable values. I was trying to dumb it down - too far, perhaps - so that
it would work with just the include.

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #7
It shouldn't do this.

I do the virtual include thing on NT4 and 2000 and works fine (the same) on
both.

Can I see some code that is not working?

-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #8
dlbjr wrote:
It shouldn't do this.

I do the virtual include thing on NT4 and 2000 and works fine (the
same) on both.

Can I see some code that is not working?


ok - I knocked-up a sample to test and you're right - it works fine. So I
looked at the dev code and realised I've coded a response.redirect and it's
the target of that call that can't access the session/application vars - it
lives in the virtual directory. Replaced the redirect with a
server.transfer and all is well in my world (till the next gotcha) - still
got some tidying to do but it's worth the pain. Many thanks for your help.

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Nicole | last post: by
4 posts views Thread by Dean | last post: by
4 posts views Thread by John Smith Jr. | last post: by
2 posts views Thread by Joe Molloy | last post: by
8 posts views Thread by Dave Wurtz | last post: by
31 posts views Thread by Harry Simpson | last post: by
9 posts views Thread by Randy | last post: by
3 posts views Thread by mikeboston | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.