.net - Find Physical Path from Microsoft.Web.Administration and path relative to it's root -


i want find physical path within iis website, of path relative root of website, using microsoft.web.administration .net assembly.

there doesn't seem single method this, wondering - following procedure best way?:

  1. get microsoft.web.administration.site object
  2. find application longest path matches beginning of path relative root
  3. strip application path beginning of path relative root, giving path relative application
  4. find virtual directory within application longest path matches beginning of path relative application
  5. strip application path beginning of path relative application, giving path relative virtual directory
  6. append path relative virtual directory (swapping / ) physical path of virtual directory give physical path want

lee

you absolutely right, right algorithm. paraphrase, make sure to:
1) find site matches (in case doing based on host name or binding (ip,port,etc)).
2) find application within site matches longest subset of remaining url.
3) find virtualdirectory within app matches longest subset of remaining url.
4) path.combine(vdir.physicalpath, "remaining of url / replaced \")

that physical path. remember nowadays lot of urls logical (in scenarios mvc or rewriting), might not have real physical path.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -