1![]()
2![]()
3
var imagePath = "<%= (Server.MapPath(".")).Replace(@"\",@"\\") %>" + "/Images/UpLoad/";

2

3
var imagePath = "<%= (Server.MapPath(".")).Replace(@"\",@"\\") %>" + "/Images/UpLoad/";几种获取asp.net应用程序的路径:
1
HttpContext.Current.Request.Url.Host//获取服务器的DNS主机名或IP地址
2![]()
3
HttpContext.Current.Request.ApplicationPath//ASP.NET应用程序的虚拟应用程序根路径
4![]()
5
/// <summary>
6
/// ASP.NET应用程序的根URL
7
/// </summary>
8
public string UrlBase
9
{
10
get
11
{
12
return @"http://" + UrlSuffix;
13
}
14
}
15![]()
16
private string UrlSuffix
17
{
18
get
19
{
20
return HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
21
}
22
}
23![]()
24
HttpContext.Current.Request.PhysicalApplicationPath//应用程序的根目录的物理路径
HttpContext.Current.Request.Url.Host//获取服务器的DNS主机名或IP地址2

3
HttpContext.Current.Request.ApplicationPath//ASP.NET应用程序的虚拟应用程序根路径4

5
/// <summary>6
/// ASP.NET应用程序的根URL7
/// </summary>8
public string UrlBase9
{10
get11
{12
return @"http://" + UrlSuffix; 13
}14
}15

16
private string UrlSuffix17
{18
get19
{20
return HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;21
}22
}23

24
HttpContext.Current.Request.PhysicalApplicationPath//应用程序的根目录的物理路径


浙公网安备 33010602011771号