Translate a filename to a URL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm currently building an application where I need to find the URL within the
current site of a full file path.

Basically what I'm looking for is the opposite transformation from
System.Web.HTTPContext.Current.Server.MapPath.

Jeff
 
This is difficult since you can have many apps in IIS using the same virtual
directory. The best you're going to get is Request.PhysicalApplicationPath
and combine that with the relative path to the file.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Actually, the scenario you suggest does the same thing as MapPath: given a
URL it gives you the absolute pathname. I'm looking for something that goes
the other way in the context of the current application.

Jeff
 
Oops, you're right -- typo and mental page fault on my part. Change my reply
from saying "Request.PhysicalApplicationPath" to "Request.ApplicationPath"
and then it's what you want.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 

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