- /// <summary>
- /// 把~/test.aspx转化成http://localhost:8088/ModuleTest/test.aspx
- /// </summary>
- /// <param name="path">如:~/test.aspx</param>
- /// <returns></returns>
- 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;
- }
- }
复制代码 |