Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply

ASP Net - How can get the current virtual path without file name?

 
Thread Tools Search this Thread
Old 10-24-2005, 07:41 PM   #1
farmer
 
Posts: n/a
Default How can get the current virtual path without file name?

Request.Path will get the current Path name with file name such as:
/Personal/Items.aspx

How can I get the only Path name such as:
/Personal

  Reply With Quote
Old 10-24-2005, 08:12 PM   #2
wizard04
 
Posts: n/a
Default Re: How can get the current virtual path without file name?

with vb, Left(Request.Path.LastIndexOf("/"))

  Reply With Quote
Old 10-24-2005, 08:14 PM   #3
Alex
 
Posts: n/a
Default Re: How can get the current virtual path without file name?

Try HttpRequest.ApplicationPath

Alex
http://www.DotNet42.com - The Answer to Your .NET Question

"farmer" <> wrote in message
news: oups.com...
> Request.Path will get the current Path name with file name such as:
> /Personal/Items.aspx
>
> How can I get the only Path name such as:
> /Personal
>



  Reply With Quote
Old 10-24-2005, 09:35 PM   #4
=?Utf-8?B?U3JlZWppdGggUmFt?=
 
Posts: n/a
Default RE: How can get the current virtual path without file name?

Have you tried Request.ApplicationPath ?


"farmer" wrote:

> Request.Path will get the current Path name with file name such as:
> /Personal/Items.aspx
>
> How can I get the only Path name such as:
> /Personal
>
>

  Reply With Quote
Old 10-24-2005, 10:32 PM   #5
farmer
 
Posts: n/a
Default Re: How can get the current virtual path without file name?

Request.ApplicationPath return current Appliction's root virtual
Path,not the path one page belongs to.

Wizard04's solution may make sense,I will try,thanks very much~

  Reply With Quote
Old 10-24-2005, 10:35 PM   #6
farmer
 
Posts: n/a
Default Re: How can get the current virtual path without file name?

Sorry Alex,HttpRequest.ApplicationPath makes no sense.

  Reply With Quote
Old 10-24-2005, 10:46 PM   #7
farmer
 
Posts: n/a
Default Re: How can get the current virtual path without file name?

Ok...but not so graceful.The much important thing is:is it reliable
enough for any URL pattern?

  Reply With Quote
Old 10-24-2005, 10:58 PM   #8
Juan T. Llibre
 
Posts: n/a
Default Re: How can get the current virtual path without file name?

What you are looking for is Page.TemplateSourceDirectory

VB.NET :
Dim currentDir As String = Page.TemplateSourceDirectory

C# :
string currentDir = Page.TemplateSourceDirectory;



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"farmer" <> wrote in message
news: oups.com...
> Sorry Alex,HttpRequest.ApplicationPath makes no sense.



  Reply With Quote
Old 10-24-2005, 10:59 PM   #9
Juan T. Llibre
 
Posts: n/a
Default Re: How can get the current virtual path without file name?

See my just-sent reply...



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"farmer" <> wrote in message
news: oups.com...
> Ok...but not so graceful.The much important thing is:is it reliable
> enough for any URL pattern?



  Reply With Quote
Old 10-24-2005, 11:07 PM   #10
farmer
 
Posts: n/a
Default Re: How can get the current virtual path without file name?

I am using C#,this makes sense:
string
ThisPath=HttpContext.Current.Request.Path.Substrin g(0,HttpContext.Current.Request.Path.LastIndexOf(" /"));

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Physical sythesis tool PALAC is not supported by Formal Verification tool Conf bbiandov Software 0 12-22-2008 04:25 AM
SONY DVD RW DW-G120A SOMETIMES FAILS...... atlantic965 DVD Video 0 06-18-2006 09:36 PM
problems backing up dvds Lawrence Traub DVD Video 11 09-27-2005 06:34 PM
Re: Ripping DVDs. Please answer the attached question. - Question.txt Stan Brown DVD Video 19 02-09-2005 10:19 PM
Burn process failed - help! Log file posted for help troubleshooting Michael Mason DVD Video 1 08-16-2004 08:24 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47