| Has Downloads | Has Images | Snippet | C# | .NET 1.1 | ASP.NET |
DownloadsPathHelperClass - 33.6 KB - ASP.NET 1.1 Solution containing PathHelper Class. |
SummaryThe ASP.NET developer is constantly needing to manage file, folder and webpage references in .NET. This can be a tedious task.
Page 1: First I will present a standard set of definitions so that we know what we mean when use words like "absolute path", "relative path", "physical path", "application path", etc.
Page 2: Then I will present some of the code to retrieve and manage this information.
Download: For the full PathHelper class which makes managing paths as easy as pie, download the sample solution above.
|
DefinitionsI will talk primarily about 4 types of paths:
- Absolute URL
- Virtual URL
- Physical Path
- Application Relative Path
I will get lazy sometimes and drop the 'URL' or 'Path' part and simply refer to them as
- Absolute
- Virtual
- Physical
- Application
|
Absolute URL: The absolute URL is is the fully qualified URL beginning with the scheme (ie. http, ftp, file, etc.)
For more on the Anatomy of a URL click here.
So, some examples of absolute URLs are:
- http://www.cambiaresearch.com
- http://www.cambiaresearch.com/c4/CategoryIndex.aspx
- http://www.cambiaresearch.com/c4/
|
Virtual URL: A virtual URL begins with a slash "/" and represents the root of the website. It is everything that follows the domain. In URL parlance it is the path, query and fragment of a URI.
Virtual URLs are _not_ relative URLs. Virtual URLs are based on the root of the website.
Some examples of virtual URLs are:
- /
- /Default.aspx
- /c4/CategoryIndex.aspx
- /c4/
- /c4/Categories.aspx?category=Article+Type%7cSnippet
|
Physical Path: The term physical path describes a fully qualified Windows-type path name that begins with a drive letter or network address and points to a specific folder or file on a computer or network.
Some examples of physical paths:
- C:\Inetpub\wwwroot
- C:\Inetpub\wwwroot\myweb\myapp\Default.aspx
- C:\Documents and Settings\steve\My Documents\My Pictures\black.png
- \\oak\PublicFolders\Steve
- \\oak\PublicFolders\Steve\Blue6.htm
|
Application Relative Path: Application path is a path that is relative to the current ASP.NET application folder. In ASP.NET 2.0 the tilda (~) was introduced to indicate an application relative path, but no such help exists in ASP.NET 1.1 and earlier.
Note that an application relative path can represent both a URL and a physical path by pointing to a folder or file. To have a valid URL or physical file one would need to convert the application path to the appropriate type using the PathHelper class I provide.
Some examples of application relative paths:
- Categories.aspx?category=Article+Type%7cSnippet
- ArticleIndex.aspx
- styles/wscms.css
|
Okay, that's it for definitions. If you've worked with this stuff you know how important it is to know what you mean be certain words.
On the next page, I will show you some code for retrieving and converting some of these different path types. |
|