1
public static string GetRootPath() { // 是否為SSL認證站點
string secure = HttpContext.Current.Request.ServerVariables["HTTPS"]; string httpProtocol = (secure == "on" ? "https://" : "http://"); // 服務器名稱
string serverName = HttpContext.Current.Request.ServerVariables["Server_Name"]; string port = HttpContext.Current.Request.ServerVariables["SERVER_PORT"]; // 應用服務名稱
string applicationName = HttpContext.Current.Request.ApplicationPath; return httpProtocol + serverName + (port.Length > 0 ? ":" + port : string.Empty) + applicationName; }