Translate a filename to a URL

Discussion in 'ASP .Net' started by Guest, Apr 11, 2005.

  1. Guest

    Guest 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
     
    Guest, Apr 11, 2005
    #1
    1. Advertisements

  2. Guest

    Brock Allen Guest

    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 Allen, Apr 11, 2005
    #2
    1. Advertisements

  3. Guest

    Guest 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
     
    Guest, Apr 11, 2005
    #3
  4. Guest

    Brock Allen Guest

    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 Allen, Apr 11, 2005
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.