






















1
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//应用程序的根目录的物理路径
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。