public class foo : System.Web.UI.Control
{
    public foo()
    {
      var a = new HyperLink(){ Text="Test", NavigateUrl="~/abc.aspx"};
      this.Controls.Add(a);
    }
}
The above code works properly, and when added to a page will successfully identify the tilde / ~ symbol and convert the url into a relative url.
However, when I change the derivation of the class to System.Web.UI.WebControl it does absolutely nothing, and leaves the tilde / ~ intact.
I had a look at System.Web.UI.Control which implements the IUrlResolutionService interface, but still can't see开发者_开发知识库m to get System.Web.UI.WebControl to resolve urls.
You can try the System.Web.VirtualPathUtility class:
public foo()
{
  var a = new HyperLink()
      { 
          Text="Test", 
          NavigateUrl=VirtualPathUtility.ToAbsolute("~/abc.aspx")
      };
  this.Controls.Add(a);
}
I usually do this to get root and them map my path:
HostingEnvironment.ApplicationVirtualPath() + "/mypath/mypage.aspx"
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论