Home > 2010 Winter BTI420 > Paths – physical and virtual – on servers that run ASP.NET Web Forms apps

Paths – physical and virtual – on servers that run ASP.NET Web Forms apps

January 28, 2010 Leave a comment Go to comments

Before we do too much with the file system on the server, we need a refresher on physical and virtual paths.

 

You need to learn (re-learn?) something about physical and virtual paths at this point in the course. We will narrow our discussion scope here to files and folders (directories).

 

Physical path

A physical path is a string that describes the location of a file or folder.

The format of the physical path depends upon the computer’s operating system platform, and its file system naming convention. Consider these two examples:

 
Windows example:
C:\inetpub\bti420_081a03\webcontent\default.aspx

UNIX example: 
/users/bti420_081a03/public_html/index.html

 

Virtual path

A virtual path is a string that describes the location of a resource (file or folder) to an application or protocol.

The format of the virtual path depends upon the application/protocol. In this course, we are working with the World Wide Web technologies, and therefore web servers and browser clients; and file and folder resources (i.e. objects) are important to us. The web server’s host address gets the resource’s virtual path appended to it to form a URL, as shown in the following example:

 
World Wide Web uniform resource locator example:
http://warp.senecac.on.ca/peter/default.aspx

(the http://warp.senecac.on.ca portion is the web server’s host address, and the /peter/default.aspx portion is the virtual path to the resource)

Both path types – physical and virtual – can be expressed using absolute or relative expressions.

 

Classes for working with physical and virtual paths

See the "…Paths…" code example for implementations of the following:

Physical paths:

Server.MapPath() method – returns a string with the physical path

Virtual paths:

Request… .Url, .ApplicationPath, .FilePath properties – return strings containing virtual paths

VirtualPathUtility… .GetDirectory, .GetFileName properties – return strings containing virtual path portions

 


Advertisements
Categories: 2010 Winter BTI420
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: