Translate virtual ~ path in app_code codebehind

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!
 
K

Karl Seguin [MVP]

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);
 

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

Top