Translate virtual ~ path in app_code codebehind

  • Thread starter Thread starter Smokey Grindle
  • Start date Start date
S

Smokey Grindle

I need to take a virtual path say "~\Site\Default.aspx" and convert it into
the correct site path in the app_code folder for codebehind. how do you go
about doing it at this level? I found it very easy to do it on a user
control and web page by using the system.web.ui.page.resolveurl function,
but unsure how to do a similar fask at the code level in the app_code
folder. Any ideas? thanks!
 
Server.MapPath will do it for you.


if (HttpContext.Current == null)
{
throw new Exception("Method must be called from a web context");
}
HttpServerUtility server = HttpContext.Current.Server;
server.MapPath(address);
 
Back
Top