473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Current URL

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.
Jun 12 '06 #1
3 1386
Have you tried?
Request.Path.Replace(System.IO.Path.GetFileName(Re quest.Path), "");

Jacob

Badass Scotsman wrote:
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.


Jun 12 '06 #2
Thank you, I owe you a pint!

Gary.
"Jacob" <ja***@reimers.dk> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Have you tried?
Request.Path.Replace(System.IO.Path.GetFileName(Re quest.Path), "");

Jacob

Badass Scotsman wrote:
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.

Jun 12 '06 #3
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

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Badass Scotsman" <ba*************@aye.net> wrote in message
news:e6*******************@news.demon.co.uk...
Thank you, I owe you a pint!

Gary.
"Jacob" <ja***@reimers.dk> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Have you tried?
Request.Path.Replace(System.IO.Path.GetFileName(Re quest.Path), "");

Jacob

Badass Scotsman wrote:
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.


Jun 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Don G | last post by:
Within the menu for my site, I have inserted 'class="current"' within the link for the current page. So the link looks somthing link: <li><a href="index.php" class="current">Home</a></li> The...
14
by: deko | last post by:
This runs, but does not narrow to current week. suggestions appreciated! SELECT lngEid, dtmApptDate, Subject, Appt_ID FROM qry002 WHERE (dtmApptDate BETWEEN DateAdd("d",-weekday()+2,) And...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
0
by: Nayt Grochowski | last post by:
Does anyone see any problem with the loading a SqlConnection into the System.Web.HttpContextCurrent.Items collection in a Page's Constructor. Then Closing and Disposing of it the OnUnload method? ...
3
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do...
2
by: Jesper Stocholm | last post by:
I have implemented role-based security within my ASP.Net application. However, it seems the role is not passed to the authentication ticket I create. I want to use it to display/hide some...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
0
by: Aaron Morton | last post by:
I'm working on a IHttpModule that handles the PreSendRequestHeaders event from the HttpApplication, if the event is raised after EndRequest then HttpContext.Current is null. If it is raised before...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
2
by: Dave | last post by:
After some digging, I discovered HttpContext.Current.Session is null when trying to access a session variable, username, in my upload.cs code which is in the App_Code folder. I just determined...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.