您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->NETCMSv1.5(Build0509)完整源码版>>NetCMS.Common/ServerInfo.cs>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:NETCMSv1.5(Build0509)完整源码版


当前文件路径:NetCMSv15/NetCMS.Common/ServerInfo.cs 文件类型
普通视图
		            
1//====================================================== 2//== (c)2008 aspxcms inc by NeTCMS v1.0 == 3//== Forum:bbs.aspxcms.com == 4//== Website:www.aspxcms.com == 5//====================================================== 6using System; 7using System.Text; 8using System.Text.RegularExpressions; 9using System.Web; 10 11namespace NetCMS.Common 12{ 13 /// <summary> 14 /// WEB信息 15 /// </summary> 16 public class ServerInfo 17 { 18 /// <summary> 19 /// 取得网站的根目录的URL 20 /// </summary> 21 /// <returns></returns> 22 public static string GetRootURI() 23 { 24 string AppPath = ""; 25 HttpContext HttpCurrent = HttpContext.Current; 26 HttpRequest Req; 27 if (HttpCurrent != null) 28 { 29 Req = HttpCurrent.Request; 30 31 string UrlAuthority = Req.Url.GetLeftPart(UriPartial.Authority); 32 if (Req.ApplicationPath == null || Req.ApplicationPath == "/") 33 //直接安装在 Web 站点 34 AppPath = UrlAuthority; 35 else 36 //安装在虚拟子目录下 37 AppPath = UrlAuthority + Req.ApplicationPath; 38 } 39 return AppPath; 40 } 41 /// <summary> 42 /// 取得网站的根目录的URL 43 /// </summary> 44 /// <param name="Req"></param> 45 /// <returns></returns> 46 public static string GetRootURI(HttpRequest Req) 47 { 48 string AppPath = ""; 49 if(Req != null) 50 { 51 string UrlAuthority = Req.Url.GetLeftPart(UriPartial.Authority); 52 if (Req.ApplicationPath == null || Req.ApplicationPath == "/") 53 //直接安装在 Web 站点 54 AppPath = UrlAuthority; 55 else 56 //安装在虚拟子目录下 57 AppPath = UrlAuthority + Req.ApplicationPath; 58 } 59 return AppPath; 60 } 61 /// <summary> 62 /// 取得网站根目录的物理路径 63 /// </summary> 64 /// <returns></returns> 65 public static string GetRootPath() 66 { 67 string AppPath = ""; 68 HttpContext HttpCurrent = HttpContext.Current; 69 if (HttpCurrent != null) 70 { 71 AppPath = HttpCurrent.Server.MapPath("~"); 72 } 73 else 74 { 75 AppPath = AppDomain.CurrentDomain.BaseDirectory; 76 if (Regex.Match(AppPath, @"\\$", RegexOptions.Compiled).Success) 77 AppPath = AppPath.Substring(0, AppPath.Length - 1); 78 } 79 return AppPath; 80 } 81 } 82} 83
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:NETCMSv1.5(Build0509)完整源码版

- 51aspx修正版简单三层留言板源码

- 51aspx无刷新仿google波形扭..

- Asp.net2.0简单入门新闻系统

- Asp.net2.0自动排班系统源码

- 三层班级留言本源码

- Asp.net物业管理系统源码

- 阳光季节(AJAX+C#开源多皮肤..

- 图表控件openflashchart的De..

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号