October 15th, 2007

How to resolve relative url’s without ResolveUrl

Sometimes you need to resolve relative url’s without ResolveUrl. If the code is executing outside a Control, for example in an IHttpHandler or business layer code somewhere that has no reference to a Control, you can’t call Control.ResolveUrl.

The System.Web.VirtualPathUtility class has some very useful method for converting from an app relative path to an absolute path:

string absoluteUrl = VirtualPathUtility.ToAbsolute(relativeUrl);

Tags: , ,

Social: kick it on DotNetKicks.com | Shout it | Add to DZone |

This entry was posted on Monday, October 15th, 2007 at 9:01 pm and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.