How can get the current virtual path without file name?

F

farmer

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
 
F

farmer

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~
 
F

farmer

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

Juan T. Llibre

What you are looking for is Page.TemplateSourceDirectory

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

C# :
string currentDir = Page.TemplateSourceDirectory;
 
F

farmer

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

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top