C# URL的封装UrlAppHelper
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Web;
?
namespace?Utility.Helper
{
????///?<summary>
????///?App操作类
????///?</summary>
????public?static?class?UrlAppHelper
????{
????????public?static?string?Url
????????{
????????????get
????????????{
????????????????if?(HttpContext.Current.Request.Url.Port?==?80)
????????????????????return?"http://"?+?HttpContext.Current.Request.Url.Host;
????????????????else
????????????????????return?"http://"?+?HttpContext.Current.Request.Url.Host?+?":"?+?HttpContext.Current.Request.Url.Port;
????????????}
????????}
????????///?<summary>
????????///?应用程序路径,以/结尾
????????///?</summary>
????????///?<returns>如:/,/cms/</returns>
????????public?static?string?Path
????????{
????????????get
????????????{
????????????????string?_ApplicationPath?=?System.Web.HttpContext.Current.Request.ApplicationPath;
????????????????if?(_ApplicationPath?!=?"/")
????????????????????_ApplicationPath?+=?"/";
????????????????return?_ApplicationPath;
????????????}
????????}
????}
}
?