相关疑难解决方法(0)

如何获取站点根URL?

我想动态获取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.

asp.net

44
推荐指数
5
解决办法
9万
查看次数

ResolveUrl/Url.Content在Classic Asp中等效

在webform/mvc中我们可以使用脚本和链接,脚本src ="Url.Content("〜/ Scripts/util.js")"

谁能告诉我经典asp中的等价物是什么?

asp.net asp.net-mvc asp-classic

6
推荐指数
1
解决办法
1257
查看次数

经典ASP - 获取完整的URL名称

我想知道是否有人可以帮助我.

我有以下网址(动态)

www.website.com/images/gal/boxes-pic004.asp
Run Code Online (Sandbox Code Playgroud)

如何使用经典ASP提取'boxes-pic004'部分

谢谢

asp-classic

6
推荐指数
2
解决办法
3万
查看次数

标签 统计

asp-classic ×2

asp.net ×2

asp.net-mvc ×1