Search code examples
c#asp.netvb.netstaticresolveurl

ASP.Net: Using System.Web.UI.Control.ResolveUrl() in a shared/static function


What is the best way to use ResolveUrl() in a Shared/static function in Asp.Net? My current solution for VB.Net is:

Dim x As New System.Web.UI.Control
x.ResolveUrl("~/someUrl")

Or C#:

System.Web.UI.Control x = new System.Web.UI.Control();
x.ResolveUrl("~/someUrl");

But I realize that isn't the best way of calling it.


Solution

  • I use System.Web.VirtualPathUtility.ToAbsolute.