zoukankan      html  css  js  c++  java
  • ASP.NET中常用的两个路径

    在做.NET编程时,因为目录结构问题往往很难使用相对路径,而用应用程序的URL绝对路径来代替。但这样会涉及到应用程序名称,端口问题,我大概写了一个获取URL路径的方法

     URL绝对路径

                #region 生成url应用程序绝对路径
                
    string absPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
                absPath = absPath.Substring(System.Web.HttpContext.Current.Request.ApplicationPath.Length);
                
    string asbUrl = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
                
    this._apppath = asbUrl.Substring(0, asbUrl.IndexOf(absPath));
                
    this._apppath.TrimEnd('/');
                
    #endregion


    硬盘物理路径和皮肤路径

                #region 生成应用程序硬盘物理路径
                
    this._physicalpath = System.Web.HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString().TrimEnd('\\');
                
    #endregion

                
    #region 生成url应用程序皮肤绝对路径
                System.Web.Configuration.PagesSection _ps 
    = (System.Web.Configuration.PagesSection)System.Configuration.ConfigurationManager.GetSection("system.web/pages");
                
    this._themename = _ps.Theme;
                
    this._fullthemepath = string.Format("{0}/App_Themes/{1}"this._apppath, _ps.Theme).TrimEnd('/');
                
    #endregion


  • 相关阅读:
    描述商品信息
    新版本Mariadb安装后相关问题的解决
    配置docker阿里云加速器
    Portainer实战
    搭建Portainer可视化界面
    如何在 Debian 9 上安装和使用 Docker
    debian10使用国内源安装docker以及一些使用方法
    帝国CMS 7.5编辑器从WORD中粘贴过来无法保留格式和图片的解决办法
    解决UEditor将div标签换成p标签的问题
    ueditor div style被过滤 解决办法
  • 原文地址:https://www.cnblogs.com/freeton/p/1693930.html
Copyright © 2011-2022 走看看