获取虚拟路径

 

~/VisitorView.aspx 转成http://localhost:15982/Synair.New.Visitor/VisitorView.aspx

 

public static string GetVirsualURL(string path

{

  path = path.Replace("~", "");

  HttpRequest request = HttpContext.Current.Request;

  string port = request.Url.Port == 80 ? "" : ":" + request.Url.Port.ToString();

  if (request.ApplicationPath == "/")

  {

    return @"http://" + request.Url.Host + port + path;

  }

  else

  {

    return @"http://" + request.Url.Host + port + request.ApplicationPath + path;

  }

}

posted @ 2010-01-30 17:30  小巩  阅读(134)  评论(0)    收藏  举报