Code Snippet
- public static string ApplicationPath()
- {
- string m_Application;
- if (HttpContext.Current.Request.ApplicationPath.Equals("/"))
- {
- m_Application = "http://" + HttpContext.Current.Request.Url.Authority;
- }
- else
- m_Application = HttpContext.Current.Request.ApplicationPath;
- return m_Application;
- }
可以获取网站路径和虚拟目录路径
本文提供了一个实用的方法来获取网站的基础路径及虚拟目录路径。通过检查当前请求的ApplicationPath属性,能够适配不同部署环境的需求。
757

被折叠的 条评论
为什么被折叠?



