我想动态获取ASP.NET应用程序的绝对根URL.这需要是以下形式的应用程序的完整根URL:http(s):// hostname(:port)/
我一直在使用这种静态方法:
public static string GetSiteRootUrl()
{
string protocol;
if (HttpContext.Current.Request.IsSecureConnection)
protocol = "https";
else
protocol = "http";
StringBuilder uri = new StringBuilder(protocol + "://");
string hostname = HttpContext.Current.Request.Url.Host;
uri.Append(hostname);
int port = HttpContext.Current.Request.Url.Port;
if (port != 80 && port != 443)
{
uri.Append(":");
uri.Append(port.ToString());
}
return uri.ToString();
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我没有HttpContext.Current范围怎么办?我遇到过这样的情况CacheItemRemovedCallback.
在webform/mvc中我们可以使用脚本和链接,脚本src ="Url.Content("〜/ Scripts/util.js")"
谁能告诉我经典asp中的等价物是什么?
我想知道是否有人可以帮助我.
我有以下网址(动态)
www.website.com/images/gal/boxes-pic004.asp
Run Code Online (Sandbox Code Playgroud)
如何使用经典ASP提取'boxes-pic004'部分
谢谢