ResolveUrl() Alternative

Published 17 September 2009 16:23 by Ross in .NET

It is common knowledge amond .NET developers that the control class has a handy method called ResolveUrl() which resolves a path containing the tilde (~) charachter to an application specific absolute path.

I often want to use this facility when I am working in code not in a class that inherits from Control. In this case there is another option using the VirtualPathUtility library. 

Using the static method VirtualPathUtility.ToAbsolute("~/my-url-here.aspx") will give exactly the same results as ResolveUrl() for when you are not working from within a control.

 


   |    Kick It on DotNetKicks.com    |    Delicious Delicious |    |    E-mail

Comments

Add comment


 

  Country flag





Ross's Blog

Ross Mason is a software devloper who lives and works in Sheffield, UK.