Translate a filename to a URL

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
 
B

Brock Allen

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.
 
G

Guest

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
 
B

Brock Allen

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.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top