我试过了
Uri uri = HttpContext.Current.Request.Url;
String host = uri.Scheme + Uri.SchemeDelimiter + uri.Host + ":" + uri.Port;
Run Code Online (Sandbox Code Playgroud)
它在我的本地机器上运行良好,但在发布到IIS7时,有一个例外
System.Web.HttpException: Request is not available in this context
Run Code Online (Sandbox Code Playgroud)
谁知道如何实现这一目标?