Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Dec 17, 2007 07:00 AM|LINK
It depends on what is the actual purpose - as many things can happen from the user request to the acual servicing of the request, you might want to use Request.PhysicalPath, you might also want to use the CurrentExecutionFilePath (this will take Server.Transfer
etc into account).
You might also be interested in the actual request (after rewrite), and use Request.Url.AbsolutePath .
Finally (?) if you want the unmodified original use new Uri(Request.RawUrl).Absolute.Path.
In cases where a physical path is involved, use System.IO.Path.GetFileName() and System.IO.Path.GetExtension() methods to extract parts of it, and use System.Web.VirtualPathUtility.GetFileName() and GetExtension() methjods when it's a part of an URL or is
a virtual path.
Why can't things just be simple? ;-)