zoukankan      html  css  js  c++  java
  • C# 取得域名及目录地址

    C# 取得域名及目录地址2007-12-17 13:06using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;

    namespace SinvanCMS.Common
    {
        /// <summary>
        /// 全局类,当前域名,物理路径
        /// </summary>
        public class Application
        {
            /// <summary>
            /// 获得url路径, http://www.my400800.cn/400ZiFeiBiaoZhun.aspx 的app部分如:http://localhost/www_dalian
            /// </summary>
            public static string AppUrl
            {
                get
                {
                    return "http://" + System.Web.HttpContext.Current.Request.Url.Host.ToString() + AppSiteName;
                }
            }

            /// <summary>
            /// 获得 http://www.my400800.cn/400ZiFeiBiaoZhun.aspx 的 部分如:www_dalian
            /// </summary>
            public static string AppSiteName
            {
                get
                {
                    string SiteAddress = "";
                    SiteAddress = System.Web.HttpContext.Current.Request.ApplicationPath.ToString();
                    if (System.Web.HttpContext.Current.Request.ApplicationPath.ToString() == "/")
                    {
                        SiteAddress = "";
                    }
                    else
                    {
                        SiteAddress = System.Web.HttpContext.Current.Request.ApplicationPath.ToString();
                    }
                    return SiteAddress.ToString();
                }
            }

            /// <summary>
            /// 获得 http://www.my400800.cn/400ZiFeiBiaoZhun.aspx 的物理路径 如:E:\SinvanProject\CMSHouseDalian
            /// </summary>
            public static string AppMapPath
            {
                get
                {
                    string ApplicationPath = System.Web.HttpContext.Current.Server.MapPath("~/");
                    if (ApplicationPath.EndsWith("\\") == true)
                    {
                        ApplicationPath = ApplicationPath.Remove(ApplicationPath.Length - 1);
                    }
                    return ApplicationPath;
                }
            }
        }
    }

  • 相关阅读:
    Spring mvc Data Redis—Pub/Sub(附Web项目源码)
    spring mvc Spring Data Redis RedisTemplate [转]
    征服 Nginx + Tomcat【转】
    Memcached笔记——(四)应对高并发攻击【转】
    征服 Redis + Jedis + Spring (三)—— 列表操作【转】
    iBatis自动生成的主键 (Oracle,MS Sql Server,MySQL)【转】
    OpenERP登录页面调整
    OpenERP QWeb模板标签笔记
    OpenERP Web开发
    ReadOnly field saved with NULL value
  • 原文地址:https://www.cnblogs.com/jishu/p/1940140.html
Copyright © 2011-2022 走看看