How can get the current virtual path without file name?

  • Thread starter Thread starter farmer
  • Start date Start date
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
 
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~
 
Ok...but not so graceful.The much important thing is:is it reliable
enough for any URL pattern?
 
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/
======================================
 
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

Back
Top