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 | Bookmark | View blog reactions

This entry was posted on Monday, October 15th, 2007 at 9:01 pm and is filed under ASP.NET, C#, Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply