Playing Chicken With Common Sense

 

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

  • 0 Comments
  • E-mail
  • Kick it!
  • Shout it
  • Bookmark and Share