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.