In Classic ASP, how do two applications make use of the same Virtual Directory?

S

SMAccount

In Classic ASP, how do two applications make use of the same Virtual
Directory?

Specifically, if a file in the Virtual Directory referenced the ASP
Application Object, how would the Server know which Application Object
to return?

Or is it the case that a Virtual Directory can only belong to one ASP
Application at a time?

I guess what I am asking is this -- if two distinct ASP Applications
both want to use the same physical directory, would they each need a
distinctly incarnated Virtual Directory to do it?
 
K

Kevin Spencer

The Application is a memory space, not tied to directories in the app. The
directory structure simply indicates to the web server (and therefore to an
Application) where to find resources used by a given web site. In other
words, although the directory structure is known by the Application, it is
not PART of the Application. Pages served are not literally documents, but
in-memory processes generated by a given Application. So, there would be no
overlap.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
 
K

Kevin Spencer

It's just semantics. I explained it, but perhaps you didn't understand.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
 
S

SMAccount

Well suppose you have two home directories, ADir and BDir, and they
both are set up to direct a browser to a virtual directory CDir.

One browser is directed to CDir from ADir and one browser is directed
to CDir from BDir. If the ASP Code in CDir accesses the ASP
Application Object, presumably one browswer will get data based on the
the Application Object associated with the ADir application and one
browser will get data based on the Application Object associated with
the BDir application. Obviously the Server Controls this, but how does
it decide?
 
K

Kevin Spencer

Again, the file is simply a resource. The virtual directory simply tells the
server how to translate an HTTP Request's URL to a physical file location.
The URL determines what ASP.Net Application handles the request. The ASP.Net
Application then goes to the physical location, opens the file, reads it,
closes it, and then parses it in its own process. Note that at this point
the file is no longer involved.

It is important to distinguish between a file system, which is managed and
"owned" by an Operating System, which is a file server, and a virtual
directory system, which is managed and "owned" by a web server, and may or
may not map to a similar file system directory structure. The file system is
stored in the OS's File Allocation Table. The virtual directory structure is
stored in the web server's MetaBase. The MetaBase may or may not be mapped
to physical file locations.

For example, in ASP.Net, you can create custom HTTP Handers, classes which
handle requests for resources made to a web site, handed off by the web
server. The HTTP Handler is specified in the web server's MetaBase as
handling a specific type of file extension, and a set of specific Request
methods (GET, POST, PUT, etc). I needed to create an ASP.Net application
that would dynamically send a text document to the client making a Request.
I tried to set the Response.ContentType header to "text/plain," which
indicates to the client that the document is plain text. However, as the
ASP.Net page had a .aspx extension, and Internet Explorer doesn't trust the
"text/plain" ContentType, as it regards it as "ambiguous," I had to come up
with a different solution. This was the HttpHandler class I wrote, which I
mapped to all requests in that web site for "*.txt" files, with any Request
Method. So, when a request comes to
http://localhost/WeatherServices/anything_at_all.txt, it is handled by my
class, and a text document is returned to the browser (even though there is
no text file on the server). Now, here's the interesting part (to you at
least). Let's say that a browser requests
http://localhost/WeatherServices/someNonExistentFolder/blah.txt. Guess what
happens? The same thing. The browser gets the same text file, even though
the folder doesn't exist, AND there is no text file. This is what I mean by
distinguishing between the OS's file system and the web server's virtual
file system. And that is why it is called "virtual."

So, again, it doesn't matter where the folder and/or file is. It matters
what URL it is sent to. The web server hands it off to that application, and
that application handles it. End of story.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
 

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

Top