asp.net mvc 获取网站的BasePath

2023-06-20,,

 public string BasePath

        {

            get

            {

                string ip_port = Request.Url.GetLeftPart(UriPartial.Authority);

                if (!string.IsNullOrWhiteSpace(ip_port) && ip_port.Contains("62.155.197.173"))

                {

                    ip_port = "http://62.155.197.173:1888";

                }

                string basePath = ip_port + "/";

                return basePath;

            }

        }