Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > C#/.NET入门教程

获取根目录的URL例如http___localhost_51898

来源:中文源码网    浏览:137 次    日期:2024-05-13 04:01:09
【下载文档:  获取根目录的URL例如http___localhost_51898.txt 】


获取根目录的URL例如http://localhost:51898
复制代码 代码如下: public static string GetRootURI() { string AppPath = ""; HttpContext HttpCurrent = HttpContext.Current; HttpRequest Req; if (HttpCurrent != null) { Req = HttpCurrent.Request; string UrlAuthority = Req.Url.GetLeftPart(UriPartial.Authority); if (Req.ApplicationPath == null || Req.ApplicationPath == "/") //直接安装在 Web 站点 AppPath = UrlAuthority; else //安装在虚拟子目录下 AppPath = UrlAuthority + Req.ApplicationPath; } return AppPath; }

相关内容