Current URL

B

Badass Scotsman

Hello,

I would like to display the current directory which an ASPX file sits
within, and display the result on page.

For example:

www.test.com/hello/test.aspx would return:
www.test.com/hello

And
www.test.com/hello/goodbye/test.aspx would return:
www.test.com/hello/goodbye

Also
www.test.com/hello/goodbye/seeyousoon/hi.aspx would return:
www.test.com/hello/goodbye/seeyousoon

I have tried lots, Request.URL, Request.PathInfo, Request.Path etc etc, none
of them work as they all want to return the FileName too :)

Gary.
 
J

Jacob

Have you tried?
Request.Path.Replace(System.IO.Path.GetFileName(Request.Path), "");

Jacob
 
K

Karl Seguin [MVP]

You should also look at the Request.Url property which is a Uri with many
properties you might find useful, such as Path and such..

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top