using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace testurl
{
public class testurl
{
// 获取当前的主机名称和应用程序路径
private static string UrlSuffix
{
get
{
string host = HttpContext.Current.Request.Url.Host;
string path = HttpContext.Current.Request.ApplicationPath;
return host + path;
}
}
/// <summary>
/// 属性,用于获取Urls的前缀
/// </summary>
public static string PathPrefix
{
get
{
string urlSuffix = UrlSuffix;
if (urlSuffix.EndsWith("/"))
{
int length = urlSuffix.Length - 1;
urlSuffix = urlSuffix.Substring(0, length);
}
return @"http://" + urlSuffix;
}
}
/// <summary>
/// 绝对路径
/// </summary>
public static string appMapPath
{
get
{
string path = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath);
return path;
}
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace testurl
{
public class testurl
{
// 获取当前的主机名称和应用程序路径
private static string UrlSuffix
{
get
{
string host = HttpContext.Current.Request.Url.Host;
string path = HttpContext.Current.Request.ApplicationPath;
return host + path;
}
}
/// <summary>
/// 属性,用于获取Urls的前缀
/// </summary>
public static string PathPrefix
{
get
{
string urlSuffix = UrlSuffix;
if (urlSuffix.EndsWith("/"))
{
int length = urlSuffix.Length - 1;
urlSuffix = urlSuffix.Substring(0, length);
}
return @"http://" + urlSuffix;
}
}
/// <summary>
/// 绝对路径
/// </summary>
public static string appMapPath
{
get
{
string path = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath);
return path;
}
}
}
}
浙公网安备 33010602011771号