ASP.NET Get physical filepath from URL

前端 未结 3 2039
囚心锁ツ
囚心锁ツ 2021-01-18 02:09

Is there a way to get the physical filepath from an ASP.NET\'s URL?

Scenerio: I have an app that is on two severs, but it will now be on lots more, and each server p

相关标签:
3条回答
  • 2021-01-18 02:30

    This is now:

    HostingEnvironment.MapPath("/");
    
    0 讨论(0)
  • 2021-01-18 02:41

    You can use HttpServerUtility.MapPath on the server side in order to get the physical path of a file, then return it in the Application or Session object, similarly to what you are doing now.

    As for the physical path of a URL - there might not be one, as URLs can be re-written.

    0 讨论(0)
  • 2021-01-18 02:53

    This Server.MapPath ( "/" ); or this HttpContext.Current.Server.MapPath ( "/" ); should give you what you need.

    0 讨论(0)
提交回复
热议问题