It seems to be a very common practice to check the URL and File paths. Many, Many scenarios require this information, and it seems that a lot of native classes are commonly overlooked. To bring awareness to classes that you may or may not know exist, I've thrown together a little table that shows several ways to get path information.
| Syntax to Request Path Information |
Result |
| Request.ApplicationPath |
/MyWebSite |
| Request.CurrentExecutionFilePath |
/MyWebSite/Paths/Paths.aspx |
| Request.FilePath |
/MyWebSite/Paths/Paths.aspx |
| Request.PhysicalApplicationPath |
c:\inetpub\wwwRoot\MyWebSite\ |
| Request.Physicalpath |
c:\inetpub\wwwRoot\MyWebSite\Path\Paths.aspx |
| Request.MapPath("/") |
c:\inetpub\wwwRoot\ |
| Request.RawUrl |
/MyWebSite/Paths/Paths.aspx |
| System.IO.Path.GetFileNameWithoutExtension(Request.PhysicalPath) |
Paths |
| System.IO.Path.GetExtension(Request.PhysicalPath) |
.aspx |
| System.IO.Path.GetDirectoryName(Request.PhysicalPath) |
c:\inetpub\wwwRoot\MyWebSite\Path |
Enjoy!!