c# 獲取網站根路徑


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; }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM