zoukankan      html  css  js  c++  java
  • 获取网站根目录Url

     /// <summary>
            /// 获取网站根目录Url
            /// </summary>
            public static string Root
            {
                get
                {
                    if (System.Web.HttpContext.Current.Cache["WebAppRoot"] == null)
                    {
                        string AppPath = string.Empty;
                        HttpContext httpCurrent = HttpContext.Current;
                        HttpRequest request;
                        request = httpCurrent.Request;
                        string UrlAuthority = request.Url.GetLeftPart(UriPartial.Authority);
                        if (request.ApplicationPath == null || request.ApplicationPath == "/")//直接安装在Web站点 
                        {
                            AppPath = UrlAuthority;
                        }
                        else //安装在虚拟子目录下
                        {
                            AppPath = UrlAuthority + request.ApplicationPath;
                        }
    
                        //return AppPath;
    
                        System.Web.HttpContext.Current.Cache.Insert("WebAppRoot", AppPath, null, DateTime.Now.AddHours(1), TimeSpan.Zero);
    
                    }
                    return (string)System.Web.HttpContext.Current.Cache["WebAppRoot"];
                }
            }
  • 相关阅读:
    matplotlib
    Scipy-数值计算库
    Django Templates
    Django Views: Dynamic Content
    Django Views and URLconfs
    Opencv读写文件
    Logistic回归
    demo
    【Python62--scrapy爬虫框架】
    【Python58--正则2】
  • 原文地址:https://www.cnblogs.com/LoVeSW/p/3425250.html
Copyright © 2011-2022 走看看